在使用 Javascript 上传之前删除选定的文件 [英] Remove selected file(s) before upload with Javascript

查看:20
本文介绍了在使用 Javascript 上传之前删除选定的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个表单,允许用户上传多张图片,如果他们不想上传那张特定的照片,这些图片会附加一个删除它们的选项.

Say I have a form that allows users to upload multiple images, which are appended with an option to remove them if they don't want to upload that particular photo.

是否可以从他们删除的文件对象中删除该值(例如,不想上传)?

Is it possible to remove the value from the files object of the one that they removed (e.g. didn't want to upload)?

推荐答案

FileList 没有删除条目的 API:

FileList has no API to remove entries:

https://developer.mozilla.org/en/DOM/FileList

但是,您可以使用 XHR2 和 AJAX 重建文件上传器并在那里过滤内容.这意味着要进行 XHR2 和 AJAX 上传,不适合传统的

上传.

However you can reconstruct File uploader using XHR2 and AJAX and filter in content there. This implies doing XHR2 and AJAX upload and is not suitable for traditional <form> uploads.

https://developer.mozilla.org/en/Using_files_from_web_applications

这篇关于在使用 Javascript 上传之前删除选定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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