FineUploader uploading multiple files as one request

杀马特。学长 韩版系。学妹 提交于 2019-12-11 03:05:00

问题


I need to upload multiple files as one request. For example, i have two required files (.csv & .ctl) that I need to save. Basically on the server side, I'm reading the .csv file and checking it against the .ctl file. If certain criteria doesn't match, I don't need to upload it. I'm not sure how or need to update the 'upload' method to read the filenames[]. Nor if I need to update this line "uploader.fineUploader('uploadStoredFiles');" to now accept the filenames[] after the user clicks "Upload now."

<script type="text/javascript">
    $(document).ready(function () {
        var filenames = [];
        var uploader = $("#fine-uploader").fineUploader({
            request: {
                endpoint: '<%= ResolveUrl("~/Handler/UploadHandler.ashx")%>'
            },
            autoUpload: false,
            text: {
                uploadButton: '<span class="glyphicon glyphicon-plus"></span> Select Files'
            },
            validation: {
                allowedExtensions: ['csv', 'ctl']
            },
            showMessage: function (message) {
                // Using Bootstrap's classes
                $('#fine-uploader').append('<div class="alert alert-danger">' + message + '</div>');
            }
        }).on('validate', function (event, fileData) {
            return $.inArray(fileData.name, filenames) < 0;
        }).on('submitted', function (event, fileId, fileName) {
            filenames.push(fileName);
        }).on('upload', function (event, fileId, fileName) {
            var fileItemContainer = $(this).fineUploader('getItemByFileId', fileId);
            $(this).fineUploader('setParams', { uploadType: 'VendorFileType', vendorId: '<%=vendorDropdownList1.CurrentVendorID %>' }, fileId);
        }).on('complete', function (event, fileName, fileName, responseJSON) {
            if (responseJSON.success) {
                var div = document.getElementById('fine-uploader-status');
                div.innerHTML = 'Upload process complete.';
            }
            else {
                var div = document.getElementById('fine-uploader-status');
                div.innerHTML = 'Upload denied.';

            }
        });

        $('#uploadSelectedFiles').click(function () {
            uploader.fineUploader('uploadStoredFiles');
        });
    });
</script>

 //here's the aspx side.
<div id="fine-uploader">
</div>
<div id="fine-uploader-status">
</div>
<button id="uploadSelectedFiles" class="btn btn-primary">
    <span class="glyphicon glyphicon-upload"></span>Upload now</button>

回答1:


Fine Uploader does not support sending multiple files in a single request. This complicates the code unnecessarily and would break some existing features. Each file is sent in a separate request. You say you are performing some server-side checks to prevent uploads, but the files have already been uploaded by the time your server is able to perform these comparisons anyway. It's not clear from your question why you need to upload multiple files in a single request, or what benefit this gives you. If you clarify, perhaps I can provide alternate suggestions.



来源:https://stackoverflow.com/questions/19255796/fineuploader-uploading-multiple-files-as-one-request

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!