How to get the file path from HTML input form in Firefox 3(如何从 Firefox 3 中的 HTML 输入表单中获取文件路径)
问题描述
我们有一个简单的 HTML 表单,带有 <input type="file">
,如下所示:
We have simple HTML form with <input type="file">
, like shown below:
<form>
<label for="attachment">Attachment:</label>
<input type="file" name="attachment" id="attachment">
<input type="submit">
</form>
在 IE7(可能还有所有著名的浏览器,包括旧的 Firefox 2)中,如果我们提交一个像//server1/path/to/file/filename"这样的文件,它可以正常工作并给出完整路径文件和文件名.
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.
在 Firefox 3 中,它只返回文件名",因为它们有新的安全功能"来截断路径,如 Firefox 错误跟踪系统(https://bugzilla.mozilla.org/show_bug.cgi?id=143220)
In Firefox 3, it returns only 'filename', because of their new 'security feature' to truncate the path, as explained in Firefox bug tracking system (https://bugzilla.mozilla.org/show_bug.cgi?id=143220)
我不知道如何克服这个新功能",因为它会导致我的 web 应用程序中的所有上传表单在 Firefox 3 上停止工作.
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.
谁能帮助找到一个解决方案来获取 Firefox 3 和 IE7 上的文件路径?
Can anyone help to find a single solution to get the file path both on Firefox 3 and IE7?
推荐答案
对于 Firefox 中的预览可以这样工作 - 在第一个示例中,附件是附件元素的对象:
For preview in Firefox works this - attachment is object of attachment element in first example:
if (attachment.files)
previewImage.src = attachment.files.item(0).getAsDataURL();
else
previewImage.src = attachment.value;
这篇关于如何从 Firefox 3 中的 HTML 输入表单中获取文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从 Firefox 3 中的 HTML 输入表单中获取文件路径


- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01