How to Get the File Path from HTML Input Form in Firefox 3

How to get full path of selected file on change of input type=‘file’ using javascript, jquery-ajax?

For security reasons browsers do not allow this, i.e. JavaScript in browser has no access to the File System, however using HTML5 File API, only Firefox provides a mozFullPath property, but if you try to get the value it returns an empty string:

$('input[type=file]').change(function () {

So don't waste your time.

edit: If you need the file's path for reading a file you can use the FileReader API instead. Here is a related question on SO: Preview an image before it is uploaded.

Retrieving the full path (server-side) of a file uploaded using Firefox?

You cannot. Actually, only IE gives this information which isn't important for the server in most cases. Neither FF nor Opera, at least, provide this info.

[UPDATE] Also tried with Safari, still no path... Somebody reported that Chrome might provide the info, although being a beta, that might change...

Perhaps you might need them in some intranet cases. In such case, you might ask the user to paste the path in a secondary input field... Not very friendly, but at least they will know they provide the info.

Actually, I know some people needed this info for some reasons, so they used JavaScript to pick up the path from the file input field and put it in an hidden field. FF developers found it was insecure (you can learn a lot from a simple path... like the login name of the user!) so prohibited such usage in FF3, making some people angry against this release...

References: Firefox 3's file upload box mentioned in Firefox 3 annoyance: Keying-in disabled in file upload control ...; also File input box disabled leads to great usability problem, among many other ones.

How do i get the full path of the file in Firefox

Basically, you can't, for security reasons.

However, the new/upcoming File API allows you to do just about everything you might want to do by getting the file's full path, without giving you the file's full path. You can read the file (yes, client-side), get a data-URI for it, etc. Example and details in this other question here on SO.

How to get the full path of the file from a file input

You cannot do so - the browser will not allow this because of security concerns. Although there are workarounds, the fact is that you shouldn't count on this working. The following Stack Overflow questions are relevant here:

  • full path from file input using jquery
  • How to get the file path from HTML input form in Firefox 3

In addition to these, the new HTML5 specification states that browsers will need to feed a Windows compatible fakepath into the input type="file" field, ostensibly for backward compatibility reasons.

  • The Mystery of c:\fakepath Unveiled

So trying to obtain the path is worse then useless in newer browsers - you'll actually get a fake one instead.

Input Type File Add File Path To A Span



Demo: get rid of C:\fakepath\ in Chrome

Or using the HTML5 file API



var f = this.files[0];
var name =;



How to get file name before upload and pass to another text input field without fakepath

You can implement change event of iput file and get[0].name;

$('input[type="file"]').change(function(e){        var fileName =[0].name;        $('[name=filename]').val(fileName.replace(/C:\\fakepath\\/i, ''));});
<script src=""></script><form name="form" method="post" enctype="multipart/form-data" ><input type="file" name="my_file" onchange="this.form.filename.value = this.value" /> <input type="text" name="filename" /><input type="submit" name="submit" value="Upload"/></form>

Related Topics

Leave a reply