Javascript fakepath

VapiSoft
VapiSoft used Ask the Experts™
on
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???
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2005
Commented:
Absent something other than just HTML and JavaScript, you will need to upload the picture then display it from your web server's hard drive.

You can always delete it afterward if it is not the desired image.
Michel PlungjanIT Expert
Top Expert 2009

Commented:
Does this one work in IE8?

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

I only have Mac here
Top Expert 2005

Commented:
No. Not for my IE8 8 version 8.0.6001.18702
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Top Expert 2005

Commented:
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
Top Expert 2005

Commented:
The </form> tag is missing from the page, but even adding that did not change my test results.

Author

Commented:
To rdivilbiss, I don't understand what you say, do you mean that there is no solution to the problem?
Michel PlungjanIT Expert
Top Expert 2009

Commented:

Author

Commented:
It is not good enough, I need a solution that works for all major browsers.
Top Expert 2005

Commented:
>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.
Michel PlungjanIT Expert
Top Expert 2009

Commented:
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

Author

Commented:
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).
Top Expert 2005

Commented:
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
Michel PlungjanIT Expert
Top Expert 2009

Commented:
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
Top Expert 2005

Commented:
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?

Author

Commented:
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.
Top Expert 2005

Commented:
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.

Author

Commented:
How do I fix it?
Michel PlungjanIT Expert
Top Expert 2009

Commented:
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

Author

Commented:
This what I implemented.
Michel PlungjanIT Expert
Top Expert 2009

Commented:
Yeah, I give up.
IE8 works if I change the settings to allow the full path

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial