久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

無法使用 JQuery-File-Upload 從文件列表中刪除文件

Cannot remove files from file list using JQuery-File-Upload(無法使用 JQuery-File-Upload 從文件列表中刪除文件)
本文介紹了無法使用 JQuery-File-Upload 從文件列表中刪除文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我在使用 JQuery-File-Upload 插件時遇到問題.我直接使用插件,而不是通過作者提供的 html 示例頁面.基本上我有一個帶有一些輸入的表格其中之一是文件輸入.第一次上傳工作正常,但是當我嘗試第二次上傳時,兩個文件都被發送(第一個是第二次),而它應該只是第二個.

I have an issue using the JQuery-File-Upload plugin. I am using the plugin directly and not through the author's provided html example pages. Basically I have a form with some inputs one of which is a file input. The first upload works fine but when I attempt a second upload both files are sent (the first one for the second time) when it should only be the second one.

例子:

  • 已選擇文件 1.
  • 文件 1 已上傳.
  • 成功.
  • 使用 jquery 我使用 $(FORM_SELECTOR).trigger('reset') 重置表單
  • 已選擇文件 2.
  • 文件 1 和文件 2 均已上傳.
  • 問題.

現在我有兩個文件 1 的副本.這不是我想要的.

Now I have two copies of file 1. This is not what I want.

顯然,如果僅能工作一次,那么使用 ajax 表單上傳并沒有多大意義,所以我認為我缺少一些東西.

Obviously there isn't much point of using an ajax form upload if it only works once so I assume that there is something I am missing.

有沒有辦法重置文件隊列?

Is there a way to reset the file queue?

檢查 data.files 對象時,我可以看到文件在表單之后被重置.我該怎么做才能將插件與輸入同步或清除 data.files.如果我手動清除 data.files 數組(通過 pop 或 data.files = [])嘗試第二次上傳不起作用.

When examining the data.files object I can see that the files are there after the form is reset. What can I do to sync the plugin with the input or clear out the data.files. If I manually clear out the data.files array (via pop or data.files = []) attempting a second upload does not work.

我這樣初始化上傳表單:

I init the upload form like this:

    $('#file-upload-form').fileupload({
    url: 'uploads/upload',
    type: 'POST',
    dataType: 'json',
    multipart: true,
    dropZone: null,
    formAcceptCharset: 'utf-8',
    autoUpload: true,
    add: function (e, data) {
        fileUploadData = data;
        $("#upload-file-btn").click(function () {
            data.submit()
                .success(function (e, status, data) {
                    console.log("success response from post", status, data);
                    var i = '<input id="file-select-input" name="files[]" multiple/>';
                    $('#file-select-input').replaceWith(i);
                })
        });
    }
});

推薦答案

我遇到了同樣的問題,我設法解決的唯一方法是在文件已上傳的情況下檢查提交回調.我只是檢查文件名是否包含在數組 fileNames 中,我在提交之前推送當前文件名,并在下一次檢查下一個文件是否存在于數組中,如果是則取消提交.

I had the same problem and the only way I've managed to solve that was to check in the submit callback if the file was already uploaded. I just check if the file name is included in the array fileNames which I push the current file name before the submission and checks on the next time if the next one is present on the array and if so cancel the submission.

var fileNames = new Array();

$('#uploadfile').fileupload({
  submit: function(e, data) ->
    var fileName = data.files[0].name;
    if ($.inArray(fileName, fileNames) === -1)
      fileNames.push(fileName);
    else
      return false;
});

這篇關于無法使用 JQuery-File-Upload 從文件列表中刪除文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

jQuery/JavaScript Library for avatar creation?(用于創建頭像的 jQuery/JavaScript 庫?)
How to do following mask input problem?(如何做以下掩碼輸入問題?)
Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 設置值/標簽的問題)
how to unit-test private methods in jquery plugins?(如何對 jquery 插件中的私有方法進行單元測試?)
stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 為垂直滾動網站配置偏移量/對齊元素?)
jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽輸入插件.當文本框獲得焦點時選擇所有內容)
主站蜘蛛池模板: 毛片免费看 | 特级毛片 | 婷婷激情五月网 | 91中文在线观看 | 亚洲精品在线观看网站 | 午夜视频在线观看网站 | 欧美中文在线 | 成人av一区二区三区 | 成人av一区二区亚洲精 | 毛片99| 黄色大片免费看 | 91亚洲精品久久久电影 | av男人的天堂av | 中文字幕日韩欧美 | 日韩中文在线视频 | 久草成人 | 国产欧美日韩一区二区三区在线 | 国产欧美日韩一区二区三区在线观看 | 久久精品视频网站 | 国产精品视频免费观看 | 国产精品久久久久久238 | 91看片视频 | 91精品一区二区三区久久久久 | 人妖videosex高潮另类 | 欧美理论片在线观看 | 欧美成人猛片aaaaaaa | 不卡视频在线 | 免费久久视频 | 久久久亚洲精品视频 | 日韩欧美在线视频播放 | 国产九九九九 | 日本电影韩国电影免费观看 | 欧美成年网站 | 国产日韩一区二区 | 久草中文网 | 日韩不卡在线 | 热99精品视频 | 欧美一区二区三区在线观看视频 | 亚洲欧美在线视频 | 久久精品一区二区三区四区 | 国产午夜精品一区二区三区四区 |