使用jquery文件上传取消单个文件

我想使用 jquery文件上传插件取消单个文件.我想用核心插件来做,不需要所有UI的东西.

在我的本地文件系统上选择文件后,文件位于何处?

解决方法

我在我的项目中这样做:为每个文件添加上传和取消按钮
$('#TestForm').fileupload({
         dataType : 'json',autoUpload : false,add : function(e,data) {
             var file=data.files[0];
             var vOutput="";
             vOutput+="<tr><td>"+file.name+"</td>"
             vOutput+="<td><input type='button' class='fileUpload' value='upload'></td>"
             vOutput+="<td><input type='button' class='fileCancel' value='cancel'></td></tr>"
             $("#TestTable").append(vOutput)
             $(".fileUpload").eq(-1).on("click",function(){
                  data.submit();
             })
             $(".fileCancel").eq(-1).on("click",function(){
                  $(this).parent().parent().remove()
             })
         }
})

如果你想要你也可以添加按钮来上传或取消所有文件,如下所示:

$("#fileUploadAll").on("click",function() {
        $(".fileUpload").click(); // click all upload buttons
    })
    $("#fileCancelAll").on("click",function() {
        $(".fileCancel").click(); //click all cancel buttons
    })

HTML:

<form id='TestForm'>
     <input type="file" id="FileSelect" name="files[]" data-url="yourURL.PHP" multiple/>
     <input type="button" value="upload all" id="fileUploadAll"/>
     <input type="button" value="cancel all" id="fileCancelAll"/>
     <table id='TestTable'></table>
</form>

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...