Wednesday, May 30, 2007

ASP.NET File Upload

Yesterday I had some problems with uploading files in ASP.NET. I've did this maybe thousand times before in PHP, CGI and some other systems, but now, it simply didn't worked.

I have used the classical FileUpload control, selected the file, pushed the button, but after Postback, the Request.Files variable has been entirely clean.

Form encoding was fine, generated HTML code looked ok. After some digging I found the ground of this problem. The FileUpload control has been placed in AJAX Update panel. After clicking the upload button, the panel (not the browser itself) tryied to send this request. And probably didn't knew how to send the file.

Placing the FileUpload outside of the UpdatePanel solved this issue. There is some kind of a workaround in this forum, but I hadn't enough time to test it. Maybe next time.

No comments: