Swfupload 实现大文件上传(MVC3)
SWFUpload V2.2.0 说明中文文档地址:
http://leeon.me/upload/other/swfupload.html#statsobject
实现效果:
Js代码:
<script src="/Scripts/SWFUpload/swfupload.js" type="text/javascript"></script>
<script src="/Scripts/SWFUpload/plugins/swfupload.queue.js" type="text/javascript"></script>
<script src="/Scripts/SWFUpload/plugins/swfupload.speed.js" type="text/javascript"></script>
<script src="/Scripts/SWFUpload/handlers.js" type="text/javascript"></script>
<script type="text/javascript">
var swfu;
window.onload = function () {
swfu = new SWFUpload({
upload_url: "/Demo/Swfupload",
flash_url: "/Scripts/SwfUpload/Flash/swfupload.swf",
file_size_limit: "300 MB",
file_types: "*.doc;*.docx;*.ppt;*.pptx;*.pdf;*.xls;*.xlsx",
file_types_description: "Select Files",
file_upload_limit: 20,
file_queue_limit: 20,
debug: false,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
// Button settings
button_image_url: "/Content/images/adddoc.gif",
button_width: "140",
button_height: "35",
button_placeholder_id: "spanButtonPlaceHolder",
button_text_left_padding: 12,
button_text_top_padding: 3,
button_action: -110,
// The event handler functions are defined in handlers.js
swfupload_preload_handler: preLoad,
swfupload_load_failed_handler: loadFailed,
file_queued_handler: fileQueued,
file_dialog_complete_handler: fileDialogComplete,
upload_start_handler: uploadStart,
upload_progress_handler: uploadProgress,
upload_success_handler: uploadSuccess,
upload_complete_handler: uploadComplete,
upload_error_handler: uploadError,
file_queue_error_handler: fileQueueError
});
$("#btnSubmit").click(function () {
if (swfu.getStats().files_queued > 0) {
swfu.startUpload();
}
});
};
function cancelFile(file_id) {
swfu.cancelUpload(file_id);
$("#" + file_id).slideUp("slow");
return false;
}
function cancelFileQueue(file_id) {
swfu.cancelUpload(file_id);
return false;
}