Link to home
Start Free TrialLog in
Avatar of VapiSoft
VapiSoft

asked on

Javascript fakepath

Hi,
I am using fileUpload in IE8 and after I do the Browse I get c:\fakepath\...
I read that this is a security thing with IE8 but that there is a workaround
(http://www.telerik.com/community/forums/aspnet-ajax/upload/ie8-upload-control-shows-quot-c-fakepath-quot.aspx).
The problem is that I cannot use this workaround because it is used from RadUpload so I cannot get the parameters: OnClientFileSelected(sender, args)
The reason I need it is because I want to show the picture (from the local disk) before I acually upload it.
So how do I get the acual (real) path???
ASKER CERTIFIED SOLUTION
Avatar of rdivilbiss
rdivilbiss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Michel Plungjan
Does this one work in IE8?

http://plungjan.name/eetest/testfileupload.html

I only have Mac here
No. Not for my IE8 8 version 8.0.6001.18702
Does work in Firefox 3.6.6
NO for Opera 10.54 Build 3423
NO for Safari 5.0 (7533.16)
NO for Chrome 5.0.375.99
The </form> tag is missing from the page, but even adding that did not change my test results.
Avatar of VapiSoft
VapiSoft

ASKER

To rdivilbiss, I don't understand what you say, do you mean that there is no solution to the problem?
It is not good enough, I need a solution that works for all major browsers.
>To rdivilbiss, I don't understand what you say, do you mean that there is no solution to the problem?

I don't think so, but I did not think you could do it at all and what you have works for Firefox, so maybe there is a solution for all major browsers. If there is it will be mplungjan that finds it.
Haha.. Actually it is a thing that is VERY tricky since it is on the border of security issues with local file access.
Some files you do not even want people to GUESS the name or be able to read the path
For example often, the path to an image would contain the user name. That is half way to logging in.

I will try tomorrow at work to see if IE8 can be fixed. I do not have high hopes
The method that works on ALL browsers is the one already given, upload the file (restricting the size on the server) and show it again. That is what facebook does too
Thanks, but don't do it or me.
I already implemented rdivilbiss's advice to upload it and then delete it.
It works OK, although if you find a solution that works for all major browsers than I would like to know it and I will change my code (because it is a better solution).
I agree with mplungjan that the issue is that you should not have access to the file path of the uploaded file, and without that you are not going to be able to show a preview.  I also agree that havinf that information available to script is a security issue which is why this is such a difficult task. I think most browsers are not going to have a way to access the filepath/filename.

There may or may not be some Flash solution as Flash has always played loose with security.

Absent that, and as mentioned by mplungjan in his last post, the cross-browser solution id to upload, then show the preview, and if the preview is rejected, delete the file from the server: which you say you already have implemented.

Regards,
Rod
However if IE8 has the same capacity of showing the DATA of the image as firefox and possibly chrome has, then the path is irrelevant
In reading several posts at the Chromium project, there appears to be a limitation in WebKit which both Chrome and Safari are built from.

In one case a Chromium developer said this violates the HTML 5 security model for getData, and the counter argument was made that Firefox has correct security measures in place, at which point the person advocating Chrome support was told to go complain in the WebKit development forum.

Meanwhile an IFrame solution was aluded to as a work around but no code was given for that.

Not a helpful or point-worthy comment, I admit; and I may have just not found the correct post yet.

If I were a betting man, I'd say WebKit and Trident will eventually adopt the Firefox method despite current HTML 5 working documents, but it could be a long time.

"B" because it isn't possible, yet? Like that is my fault?
Basically the first reply was plain "it can't be done" so  felt it A will be too much for this.
fter that there as a very large discussion from several experts how to solve the problem and if it is possible. I should have split the points between all the experts that comment on this.
Thia isn't college. When the answer is "you can't do that" it is based on years of experience you do not have or you would not be asking the question. As it turns out the anwser was "spot on."

I'll be sure to not answer any of your questions in the future.
How do I fix it?
Yeah - being a member since 2006 you aught to not give "B" grades to "Not Possible"
And the large discussion is only between me and Rod ;) And only because we want to visit all paths for your solution
This what I implemented.
Yeah, I give up.
IE8 works if I change the settings to allow the full path