Playing around with jQuery and jTemplate and I had the following problem: On a page created with jTemplate I could not use asp:FileUpload Control. Additionally it would of course be better to have an Ajax / jQuery control as this would better integrate into a jQuery website. There are several jQuery Fileupload controls, and Ajax-Upload is my favorite, e.g. because it allows multiple fileupload and does not require Flash. Andrew Valums, the creator of the Ajax-Upload, has posted a C#-Example but as it’s just posted in the comments it might be missed easily. Additionally I needed it for Visual Basic so I’ve transfered it and wrote this short blog entry.
// max size 1 MB
In the webservice I then use the following code. The code is shortened to the basics, of course you should add a check whether the filename already exists etc. but it should only demonstrate how to save the uploaded file.
'get reference to posted file and do what you want with this file
.Context.Request.Files.Count = 0
'Firefox does not upload it as file
IO.FileStream(ImportPath & Filename, IO.FileMode.Create)
BytesRead = Context.Request.InputStream.Read(buffer, 0, Length)
fileStream.Write(buffer, 0, BytesRead)
BytesRead > 0
' log error hinting to set the write permission of ASPNET or the identity accessing the code
postedfile = TryCast(
That’s it. Tested with IE 8 and Firefox 3.6.