A while back, I posted an AJAX-Style file upload demo. While using that technique in a current project, I discovered a bit of a bug. In FireFox, you can dynamically set the EncType of a form element to be "multipart/form-data" for file uploads; however, this does not work in Internet Explorer (IE). Apparently in IE, you have to set the "encoding" of the form rather than the "enctype". The good news is, you can set both values without concern and this will take care of the problem:
// Using jQuery, set both the enctype and the encoding // attributes to be multipart/form-data. $( "form#upload-form" ) .attr( "enctype", "multipart/form-data" ) .attr( "encoding", "multipart/form-data" ) ;
Minor note, but wanted to write this down to help me remember.
Want to use code from this post? Check out the license.