jQuery-File-上传如何以正确的方式发送文件

时间:2012-06-12 12:41:30

标签: jquery asp.net file-upload

我有下面的代码应该使用ajax将文件发送到服务器,但jQuery-File-Upload不发送它。怎么了?我在文档中做了所有事情。

    <div id="uploadDialog" title="Import files">


            <input id="fileupload" type="file" name="files[]" multiple data-url="/FileReceiver.ashx"
                data-sequential-uploads="true" data-form-data='{"script": "true"}'>

            <button id="btnUpload">Import</button>
        </div>
     $('#fileupload')
        .bind('fileuploadadd', function (e, data) { alert("0"); })
        .bind('fileuploadsubmit', function (e, data) { alert("1"); })
        .bind('fileuploadsend', function (e, data) { alert("2"); })
        .bind('fileuploaddone', function (e, data) { alert("3"); })
        .bind('fileuploadfail', function (e, data) { alert("4"); })
        .bind('fileuploadalways', function (e, data) { alert("5"); })
        .bind('fileuploadprogress', function (e, data) { alert("6"); })
        .bind('fileuploadprogressall', function (e, data) { alert("7"); })
        .bind('fileuploadstart', function (e) { alert("8"); })
        .bind('fileuploadstop', function (e) { alert("9"); })
        .bind('fileuploadchange', function (e, data) { alert("10"); })
        .bind('fileuploadpaste', function (e, data) { alert("11"); })
        .bind('fileuploaddrop', function (e, data) { alert("12"); })
        .bind('fileuploaddragover', function (e) { alert("13"); });

        $("#btnUpload").click(function () {           
            var filesList = $('#fileupload').attr("files");
//1-st variant 
           $('#fileupload').fileupload('add', { files: filesList, url: '/FileReceiver.ashx' });
//2-nd variant 
            $('#fileupload').fileupload('send', { files: filesList });
        });

0 个答案:

没有答案