87,992
社区成员
发帖
与我相关
我的任务
分享
//当文件上传完毕并且服务器返回200状态时,uploadSuccess事件将触发。
function uploadSuccess(file, serverData) {
try {
file.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file
var progress = new FileProgress(file, this.customSettings.progress_target); //??没看到定义啊this.customSettings.progress_target
progress.setComplete();
progress.setStatus("正在转换视频,请稍候...");
progress.toggleCancel(false);
if (serverData === " ") { this.customSettings.upload_successful = false; }
else {this.customSettings.upload_successful = true;
//alert(serverData);
var txtVname = document.getElementById("vname");
if (txtVname != null)
txtVname.value = serverData;
else
progress.setStatus("视频上传并转换成功");
}
} catch (e) { this.debug(e); }
}
function uploadComplete(file) {
try {
if (this.customSettings.upload_successful) {
this.setButtonDisabled(true);
if(typeof(submitRequired)!="undefined"&&submitRequired)
uploadDone();
} else {
file.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file
var progress = new FileProgress(file, this.customSettings.progress_target);
progress.setError();
progress.setStatus("文件被拒收");
progress.toggleCancel(false);
var txtFileName = document.getElementById("videoPath");
txtFileName.value = "";
validateForm();
alert("上传文件出错,服务器拒绝接收文件");
}
} catch (e) {this.debug(e); }
}
//根据error code参数的值你可以得出SWFUpload.UPLOAD_ERROR中的一个常量(译者注:表示具体错误)
function uploadError(file, errorCode, message) {
try {
if (errorCode === SWFUpload.UPLOAD_ERROR.FILE_CANCELLED) {
// Don't show cancelled error boxes //如果是用户取消上传,不显示错误信息
return;
}
var txtFileName = document.getElementById("videoPath");
txtFileName.value = ""; //将文本框内的文件名清空
validateForm(); //验证表单
// Handle this error separately because we don't want to create a FileProgress element for it.
switch (errorCode) {
case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
alert("配置出错:上传路径丢失"); //估计是upload_url:没有设置
this.debug("Error Code: No backend file, File name: " + file.name + ", Message: " + message);
return;
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: //file_upload_limit:超过这个设置
alert("您只可以上传一个文件");
this.debug("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
return;
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: //取消上传
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: //停止上传
break;
default:
alert("上传出错,请稍后重试"); //
this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
return;
}
file.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file
var progress = new FileProgress(file, this.customSettings.progress_target); //??progress_target 没有设置啊
progress.setError();
progress.toggleCancel(false);
switch (errorCode) {
case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
progress.setStatus("上传出错");
this.debug("Http错误,文件名:" + file.name + ", 错误消息: " + message);
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
progress.setStatus("上传失败");
this.debug("上传失败,文件名: " + file.name + ", 文件大小: " + file.size + ", 错误消息: " + message);
break;
case SWFUpload.UPLOAD_ERROR.IO_ERROR:
progress.setStatus("服务器(IO)错误");
this.debug("IO错误, 文件名: " + file.name + ", 错误消息: " + message);
break;
case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
progress.setStatus("安全性错误");
this.debug("安全性错误, 文件名: " + file.name + ", 错误消息: " + message);
break;
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
progress.setStatus("上传被取消");
this.debug("上传被取消, 文件名: " + file.name + ", 错误消息: " + message);
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
progress.setStatus("上传停止");
this.debug("上传停止, 文件名: " + file.name + ", 错误消息: " + message);
break;
}
} catch (ex) {
}
}