Let me first set the background for this discussion. I have a client that wants to ask for some information like name, address, education, etc. and wants them to attach a document. They want the content form and the file to be attached to an email and sent to a recipient. At first this seemed no problem but then the requirements where added that required all of this to happen using jquery and ajax. (This seems more professional) This completely changed everything. This article along with the next few articles will go through the thought process of some “catchas” and how they were solved. I realize that someone might have a better “mousetrap” but this is how I accomplished it. I spent a lot of time on Google and reading a lot. Articles like…
- Web API: how to access multipart form values when using MultipartMemoryStreamProvider
- Jquery AJAX Form Submit Example
- Async File Uploads with MVC, WebAPI and Bootstrap
- Upload files with HTTPWebrequest (multipart/form-data)
- using MultipartFormDataStreamProvider and ReadAsMultipartAsync
- WebApi: File upload and download using JQuery and submit button
But (as typically the case) each one did not exactly fit what I needed.
Here are the challenges and restrictions that I had to overcome.
- All the samples presented were in C+ and in many cases use MVC (Creates problems if you have to use VB and web.api’s)
- Not all people will use the latest browser. (Using FormData
- Need to use async uploading. (Creates problems trying to use standard multi-part form functionality in html)
- There is more than just a file begin sent. (Creates a problem with parsing the file from the form-data)
- Document attachment cannot be saved to web site (Creates a problem with attaching a document to an email).
- I have to use Visual Basic without MVC (Creates a problem with using above solutions)
- Cannot use Json responses because of using HTTPResponse (Creates a problem with older browsers)
Within each of these restrictions, I had even more challenges but I can say that I have overcome them and hopefully help someone else.
Over the coming weeks I will be addressing each of these restrictions and how I solved them. I want to thank each of the authors above mentioned articles for without them this would have taken me a lot longer to figure out.
Note: As I complete each resolution I will provide a link to that article. As always please drop a note if you see some area that I can improve in and I will make note of it.
Looking for quality web hosting? Look no further than Arvixe Web Hosting