Wednesday, September 2, 2009

Hi all,
I found something useful for a change and thought I'd share. :) While trying to check the accuracy of a specific origin path of a file to be uploaded to a destination directory from a web page I found that some newer browsers handle this a bit differently. For example, if the user browses to the file C:\Docs\myfile.doc on their machine from a web page, from an input box with type "file", the .value property of the input box in the C# code will return C:\fakepath\myfile.doc in IE8 and some other newer browsers. This MSDN article tells you how to get around that, only it is up to the user to do so by manually changing a security setting in IE8.

Since I can control the browser type and settings of the users for this project it's no big deal. But unless someone can find a way to read the entire file path in IE8, all you can call is the file name via the code. I'm sure this isn't going to be a common occurance, but I thought it was worth noting.

Another example:
I have this code...

if (File1.Value != @"C:\KneeOA\Back_End\KneeOA_Back_End.mdb")

...which is checking the path of the file to be uploaded because it has to be very specific for this project. IE8 only returns "KneeOA_Back_End.mdb" for "File1.Value" which is not really helpful. IE7 and earlier do return the whole path and therefore can check it for accuracy without having to change an IE security setting.

No comments: