[thelist] Local path of uploaded file

Sarah Adams sarahwbs at gmail.com
Wed Oct 28 08:29:04 CDT 2009

> So I have a form that uploads a file, along with some text fields. PHP
> validates the form, and returns the visitor to the form if not all
> criteria are met.
> The upload form is then empty.
> My question is: how do I keep the local path + file name in the <input
> type="file" /> input field?
> Google points me back in time to 2003:
> http://forums.devshed.com/php-development-5/getting-the-remote-file-path-from-input-type-file-56068.html
> where it should be provided by js. However, when I test it, it only
> returns the original file name (same as $_FILES['userfile']['name'] ).
> Actually FF returns the file name "test-file.pdf" only, IE returns
> "C:\fakepath\test-file.pdf" whilst the file came from a network share.
> Does anyone have a suggestion, or provide a hyperlink to a working example?

It's not possible without replacing the file input with a flash or java
gadget of some sort. File inputs are read-only for security reasons.
Allowing javascript access to the local file system would be very, very bad.

sarah adams
web developer & programmer

More information about the thelist mailing list