0

就目前而言,我的代码适用于 HTML5 和 Silverlight。但是,当我使用 Flash 或 HTML4 时,上传表单会停止。当我检查上传的目录时,只上传了第一个文件。截屏

这是我的上传者之一的javascript:

$("#origShapeUploader").pluploadQueue({

runtimes: 'flash,html4',
url: 'upload.aspx?originals=yes', //with a query string of yes, the files being uploaded won't be given a prefix of 'MOD'
max_file_count: maxfiles,
filters: [
    { title: "Shape files", extensions: "shp,dbf,prj,shx"} //these are the only file types allowed
    ],
multi_selection: true,
flash_swf_url: '/javascript/plupload.flash.swf', //in case silverlight and html5 support doesn't exist
silverlight_xap_url: '/javascript/plupload.silverlight.xap', //silverlight browser extension


});

这对我来说是尖叫的服务器端处理程序问题,所以这是我处理上传的代码,MOD 前缀用于我程序的不同部分。

    if (Request.Files.Count > 0)
    {

    int chunk = Request["chunk"] != null ? int.Parse(Request["chunk"]) : 0;
    string fileName = Request["name"] != null ? Request["name"] : string.Empty;

    HttpPostedFile fileUpload = Request.Files[0];

    var uploadPath = Server.MapPath("~/uploaded-files");
    if (Request.QueryString["originals"] == "yes")
    {
        using (var fs = new FileStream(Path.Combine(uploadPath, fileName), chunk == 0 ? FileMode.Create : FileMode.Append))
        {
            var buffer = new byte[fileUpload.InputStream.Length];
            fileUpload.InputStream.Read(buffer, 0, buffer.Length);
            fs.Write(buffer, 0, buffer.Length);
        }
    }
    else
    {
        using (var fs = new FileStream(Path.Combine(uploadPath, "MOD" + fileName), chunk == 0 ? FileMode.Create : FileMode.Append))
        {
            var buffer = new byte[fileUpload.InputStream.Length];
            fileUpload.InputStream.Read(buffer, 0, buffer.Length);
            fs.Write(buffer, 0, buffer.Length);
        }


    }

}

4

1 回答 1

1

您至少需要从后端返回一些东西——OK、DONE 或某种 json 确认。一些 Flash 播放器存在一个错误,即如果服务器未返回任何输出,它们将无法识别请求完成。至于 HTML4,它就是它的工作原理。

于 2013-06-21T09:05:58.230 回答