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 输入表单中获取文件路径


基础教程推荐
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01