There is a fundamental problem with File Uploads in web browsers. If there is anything that is going to cause the file to be invalid you can't let the user know until after they have uploaded the entire file.
"Life Sucks" Rant
If the file is of the wrong type, wrong size, or doesn't meet some of other criteria it doesn't matter. The browser happily sends the complete file to the web server. Then you can check out the file and return some sort of status message.
Great! My user, in his remote village (I live in Alaska) gets on his Dial-Up, or uses the slow satellite connection at the local community center. He attaches his 20MB resume, waits 20 minutes while it uploads and then gets a nice message back saying: "The file was too big. You just burned away 20 minutes of your life. Would like to burn away another 20? Please try again."
I've looked in to a few solutions. We are an ASP.Net shop and I checked out a couple controls that do file upload progress and file size check, etc. They are nifty but don't really cut it. They are too fragile. And I don't want to fix one problem while introducing a dozen new ones.
It turns out that since Flash 8 you can do uploads via the browsers Flash Plugin and so I discovered SWF Upload. It's pretty nice and avoids some of the pitfalls that the other "browser only" solutions have to face.
Everything seemed rosy. However, today, the thing just stopped working and always returns an IOError. Even the unmodified sample code stopped working.
Oh well. I guess I'll just wait until the browser vendors fix the File control.
Getting SWFUpload to work in ASP.Net
SWFUpload returns an error if you try to wedge the thing inside the <form runat="server"> tags. This has to do with the way things get arranged inside the DOM when the Flash is dynamically added to the page.
This can be done by modifying the mmSWFUpload.js file. Find the line:
n.innerHTML = this.getSWFHTML();
in the "write" method and replace it with this:
var body = document.getElementsByTagName("body");
var container = document.createElement("div");
container.innerHTML = this.getSWFHTML();
There you go. That'll do it. The SWFUpload flash object is added outside the FORM tags and works correctly. Good luck with the rest.