目前,我的代码适用于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);
}
}
}
答案 0 :(得分:1)
你需要至少从后端返回一些内容 - OK,DONE或某种类型的json确认。如果没有从服务器返回输出,某些Flash播放器会出现无法识别请求完成的错误。至于HTML4,它就是它的工作原理。