<p>We have simple HTML form with <code>&lt;input type="file"&gt;</code>, like shown below:</p>

<pre><code>&lt;form&gt;
  &lt;label for="attachment"&gt;Attachment:&lt;/label&gt;
  &lt;input type="file" name="attachment" id="attachment"&gt;
  &lt;input type="submit"&gt;
&lt;/form&gt;
</code></pre>

<p>In IE7 (and probably all famous browsers, including old Firefox 2), if we submit a file like '//server1/path/to/file/filename' it works properly and gives the full path to the
file and the filename.</p>

<p>In Firefox 3, it returns only 'filename', because of their new 'security feature' to truncate the path, as explained in Firefox bug tracking system (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=143220" rel="noreferrer">https://bugzilla.mozilla.org/show_bug.cgi?id=143220</a>)</p>

<p>I have no clue how to overcome this 'new feature' because it causes all upload forms in my webapp to stop working on Firefox 3.</p>

<p>Can anyone help to find a single solution to get the file path both on Firefox 3 and IE7?</p>

[{'answer_id': 81227, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>Simply you cannot do it with FF3.</p>\n\n<p>The other option could be using applet or other controls to select and upload files.</p>\n'}, {'answer_id': 81249, 'author': 'LohanJ', 'author_id': 11286, 'author_profile': 'https://Stackoverflow.com/users/11286', 'pm_score': 0, 'selected': False, 'text': '<p>Have a look at <a href="http://www.mozilla.org/projects/xpcom/" rel="nofollow noreferrer">XPCOM</a>, there might be something that you can use if Firefox 3 is used by a client.</p>\n'}, {'answer_id': 81332, 'author': 'Victor', 'author_id': 14514, 'author_profile': 'https://Stackoverflow.com/users/14514', 'pm_score': 0, 'selected': False, 'text': '<p>This is an example that could work for you if what you need is not exactly the path, but a reference to the file working offline.</p>\n\n<p><a href="http://www.ab-d.fr/date/2008-07-12/" rel="nofollow noreferrer">http://www.ab-d.fr/date/2008-07-12/</a></p>\n\n<p>It is in french, but the code is javascript :)</p>\n\n<p>This are the references the article points to:\n<a href="http://developer.mozilla.org/en/nsIDOMFile" rel="nofollow noreferrer">http://developer.mozilla.org/en/nsIDOMFile</a>\n<a href="http://developer.mozilla.org/en/nsIDOMFileList" rel="nofollow noreferrer">http://developer.mozilla.org/en/nsIDOMFileList</a></p>\n'}, {'answer_id': 181526, 'author': 'PhiLho', 'author_id': 15459, 'author_profile': 'https://Stackoverflow.com/users/15459', 'pm_score': 2, 'selected': False, 'text': "<p>Actually, just before FF3 was out, I did some experiments, and FF2 sends only the filename, like did Opera 9.0. Only IE sends the full path. The behavior makes sense, because the server doesn't have to know where the user stores the file on his computer, it is irrelevant to the upload process. Unless you are writing an intranet application and get the file by direct network access!</p>\n\n<p>What have changed (and that's the real point of the bug item you point to) is that FF3 no longer let access to the file path from JavaScript. And won't let type/paste a path there, which is more annoying for me: I have a shell extension which copies the path of a file from Windows Explorer to the clipboard and I used it a lot in such form. I solved the issue by using the DragDropUpload extension. But this becomes off-topic, I fear.</p>\n\n<p>I wonder what your Web forms are doing to stop working with this new behavior.</p>\n\n<p>[EDIT] After reading the page linked by Mike, I see indeed intranet uses of the path (identify a user for example) and local uses (show preview of an image, local management of files). User Jam-es seems to provide a workaround with nsIDOMFile (not tried yet).</p>\n"}, {'answer_id': 1169691, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>This is an alternate solution/fix... In FF3, You can retrieve file\'s full path in a textbox instead of file browse box. And that too... By drag/dropping the file! </p>\n\n<p>You can drag drop your file into a text box in your html page. and it will display the file\'s complete path. This data can transferred to your server easily or manipulate them.</p>\n\n<p>All you have to do is to use the extension DragDropUpload</p>\n\n<p><a href="http://www.teslacore.it/wiki/index.php?title=DragDropUpload" rel="nofollow noreferrer">http://www.teslacore.it/wiki/index.php?title=DragDropUpload</a></p>\n\n<p>This extension will helps you in drag dropping files into your File Browse (Input file) box. But still you wont able to get the file full path, If you try to retrieve.</p>\n\n<p>So, I tweaked this extension a little. In the way I can drag drop a file on to any "Text Input" box and get the file full path. And thus I can able to get the file full path in FF3 Firefox 3.</p>\n'}, {'answer_id': 1308506, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>One extremely ugly way to resolve this is have the user manually type the directory into a text box, and add this back to the front of the file value in the JavaScript.</p>\n\n<p>Messy... but it depends on the level of user you are working with, and gets around the security issue.</p>\n\n<pre><code>&lt;form&gt;\n    &lt;input type="text" id="file_path" value="C:/" /&gt;\n    &lt;input type="file" id="file_name" /&gt;\n    &lt;input type="button" onclick="ajax_restore();" value="Restore Database" /&gt;\n&lt;/form&gt;\n</code></pre>\n\n<p>JavaScript</p>\n\n<pre><code>var str = document.getElementById(\'file_path\').value;\nvar str = str + document.getElementById(\'file_name\').value;\n</code></pre>\n'}, {'answer_id': 1995751, 'author': 'houba', 'author_id': 242775, 'author_profile': 'https://Stackoverflow.com/users/242775', 'pm_score': 3, 'selected': False, 'text': '<p>For preview in Firefox works this - attachment is object of attachment element in first example:</p>\n\n<pre><code>           if (attachment.files)\n             previewImage.src = attachment.files.item(0).getAsDataURL();\n           else\n             previewImage.src = attachment.value;\n</code></pre>\n'}, {'answer_id': 4381889, 'author': 'Jay', 'author_id': 534269, 'author_profile': 'https://Stackoverflow.com/users/534269', 'pm_score': 2, 'selected': False, 'text': '<p>We can\'t get complete file path in FF3. The below might be useful for File component customization.</p>\n\n<pre><code>&lt;script&gt;\n\nfunction setFileName()\n{\n    var file1=document.forms[0].firstAttachmentFileName.value; \n\n    initFileUploads(\'firstFile1\',\'fileinputs1\',file1);\n    }\nfunction initFileUploads(fileName,fileinputs,fileValue) {\n    var fakeFileUpload = document.createElement(\'div\');\n    fakeFileUpload.className = \'fakefile\';\n    var filename = document.createElement(\'input\');\n    filename.type=\'text\';\n    filename.value=fileValue;\n    filename.id=fileName;\n    filename.title=\'Title\';\n    fakeFileUpload.appendChild(filename);\n    var image = document.createElement(\'input\');\n    image.type=\'button\';\n    image.value=\'Browse File\';\n    image.size=5100;\n    image.style.border=0;\n    fakeFileUpload.appendChild(image);\n    var x = document.getElementsByTagName(\'input\');\n    for (var i=0; i&amp;lt;x.length;i++) {\n        if (x[i].type != \'file\') continue;\n        if (x[i].parentNode.className != fileinputs) continue;\n        x[i].className = \'file hidden\';\n        var clone = fakeFileUpload.cloneNode(true);\n        x[i].parentNode.appendChild(clone);\n        x[i].relatedElement = clone.getElementsByTagName(\'input\')[0];\n        x[i].onchange= function () {\n            this.relatedElement.value = this.value;\n        }}\n    if(document.forms[0].firstFile != null &amp;&amp; document.getElementById(\'firstFile1\') != null)\n    {\n    document.getElementById(\'firstFile1\').value= document.forms[0].firstFile.value;\n    document.forms[0].firstAttachmentFileName.title=document.forms[0].firstFile.value;\n    }\n}\n\nfunction submitFile()\n{\nalert( document.forms[0].firstAttachmentFileName.value);\n}\n&lt;/script&gt;\n&lt;style&gt;div.fileinputs1 {position: relative;}div.fileinputs2 {position: relative;}\ndiv.fakefile {position: absolute;top: 0px;left: 0px;z-index: 1;}\ninput.file {position: relative;text-align: right;-moz-opacity:0 ;filter:alpha(opacity: 0);\n    opacity: 0;z-index: 2;}&lt;/style&gt;\n\n&lt;html&gt;\n&lt;body onLoad ="setFileName();"&gt;\n&lt;form&gt;\n&lt;div class="fileinputs1"&gt;\n&lt;INPUT TYPE=file NAME="firstAttachmentFileName" styleClass="file" /&gt;\n&lt;/div&gt;\n&lt;INPUT type="button" value="submit" onclick="submitFile();" /&gt;\n&lt;/form&gt;\n&lt;/body&gt;\n&lt;/html&gt;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/81180', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/446104/']