views:

911

answers:

2

I am having a file upload control in my page. I want to get the full path of the uploaded file by javascript. i have written

document.getElmentById('fileControl").value;

It is showing the full path in IE but in mozilla 3.5 it is showing only the filename not the path.

So how to solve this problem ?

A: 

Firefox doesn't let you see the path to the file by default - apparently there is a workaround for it but it requires the user to go to about:config and change a setting, which let's face it, ain't going to happen most of the time.

If you absolutely need this (I can't see why though) then you could look at using Flash as a cross-browser alternative, google for Flash and file uploads.

Otherwise, you'll need to work with the limitation here (which in my mind is a very good one!)

Sam
which setting we have to change for that in Firefox ?
You can't alter settings to a client browser from your web application.
rahul
No i don't want to do that but i only want to know :)
I'm pretty sure you can't get the file path from Flash either - the file upload security sandbox prevents anything more than getting a handle to the bytestream which the user selected through a closed dialog.
Rex M
but i have write a demo which i can show it to someone so i can adjust with any approach coz this thing will not get published anyway.
Why do you want to get the filepath of a file located in a remote machine?
rahul
+4  A: 

This will be a security issue. Reading the file path of the client machine is not a good idea and won't be allowed by most of the browsers.

rahul