Today is a good day to code

Iframe form submission and the difference between FireFox and IE

Posted: December 31st, 1969 | Author: | Filed under: Uncategorized | No Comments »

Iframe form submission and the difference between FireFox and IE

Picture of IrvinWorking with C# and doing asynchronous file uploads with invisible iframes is pretty easy. The hard part is on the C# end. When a form is created with the type attribute set to of multipart/form-data, the two browsers behave very differently. IE sends the entire path to the client file, where FireFox sends only the file name.

The problem came up because I was doing some parsing of the filename using the HttpPostedFile class. This is a really easy way to get at different attributes of an uploaded file relevant to the web. The problem with this object is that the filename member contains the entire path if the file was uploaded with IE, and the filename only if the file was submitted using FireFox. This is a very small thing, but if you are using the filename member to create fully qualified paths, then you will run into problems since there is no way to create a fully qualified path using the whole path from the posted file. What you will end up with is something like D:InetpubimagesC:userpathuserimagesimagename.png. Any system will puke when you feed it that, so if you are doing forms with IE and using C#, make sure to parse the filename out of the filename member.