【IT专家】使用带有.change()事件的输入类型=“文件”字段上传文件并不总是在IE和Chrome中触发[重复]

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

本文由我司收集整编,推荐下载,如有疑问,请与我司联系使用带有.change()事件的输入类型=“文件”字段上传文件并不总是在

IE 和Chrome 中触发[重复]

使用带有.change()事件的输入类型=“文件”字段上传文件并不总是在IE 和

Chrome 中触发[重复][英]Upload files using input type=“file” field with .change() event not always firing in IE and Chrome [duplicate]I have simple piece of code to upload files: 我有一段简单的代码来上传文件:

$(document).ready(function () { $(“.attachmentsUpload input.file”).change(function () { $(‘form’).submit();form action=“/UploadHandler.ashx”method=“post”enctype=“multipart/form-data”input type=“file”name=“file” / /form While I click

on input and then select a file in dialog box, I’m submitting this file using ajax. This is not important part here. Important part is, that while I select the same file second time in the

dialog box, just after submitting the first file, the .change() event does not fire in IE and Chrome. But while I choose different file, the event fires and works properly. Under Firefox it is firing all the time.

当我点击输入然后在对话框中选择一个文件时,我正在使用ajax 提交此文件。这

不是重要的部分。重要的是,当我在对话框中第二次选择相同的文件时,在提交第

一个文件之后,.change()事件不会在IE 和Chrome 中触发。但是当我选择不同的

文件时,事件会触发并正常工作。在Firefox 下,它一直在开火。

How to workaround this, to work as expected (as in Firefox) ?

如何解决这个问题,按预期工作(如在Firefox 中)?

29

Description This happens because the value of the input field (the selected filepath) does

not change if you select the same file again.

发生这种情况是因为如果再次选择同一文件,则输入字段(所选文件路径)的值

不会更改。

相关文档
最新文档