如何从 Firefox 3 中的 HTML 输入表单获取文件路径 [英] How to get the file path from HTML input form in Firefox 3

查看:36
本文介绍了如何从 Firefox 3 中的 HTML 输入表单获取文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个带有 的简单 HTML 表单,如下所示:

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 输入表单获取文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆