Javascript 使用Plupload在表单提交按钮上载文件
我正在使用最新版本的Plupload(2.1)-UI小部件 当我单击“上载文件”时,它会正确上载所有文件 但当我试图用我的表单提交按钮上传文件时。它不起作用。它只是显示了一点文件上传,然后最终提交表格,而没有完成文件上传 这是我的密码:Javascript 使用Plupload在表单提交按钮上载文件,javascript,php,jquery,plupload,Javascript,Php,Jquery,Plupload,我正在使用最新版本的Plupload(2.1)-UI小部件 当我单击“上载文件”时,它会正确上载所有文件 但当我试图用我的表单提交按钮上传文件时。它不起作用。它只是显示了一点文件上传,然后最终提交表格,而没有完成文件上传 这是我的密码: jj = jQuery.noConflict(); jj(function() { jj("#flash_uploader_other").plupload({ runtimes: "html5,flash,silverlight,html4",
jj = jQuery.noConflict();
jj(function() {
jj("#flash_uploader_other").plupload({
runtimes: "html5,flash,silverlight,html4",
url: "/external/uploader-new/upload.php",
max_file_size: "10mb",
chunk_size: "1mb",
unique_names: true,
filters: [
{
title: "jpg,xls,csv,doc,pdf,docx,xlsx",
extensions: "jpg,xls,csv,doc,pdf,docx,xlsx"
}
],
flash_swf_url: "/external/uploader-new/js/Moxie.swf",
silverlight_xap_url: "/external/uploader-new/js/Moxie.xap"
});
// Handle the case when form was submitted before uploading has finished
jj("form").submit(function(e) {
// Files in queue upload them first
if (jj("#flash_uploader_other").plupload("getFiles").length > 0) {
// When all files are uploaded submit form
jj("#flash_uploader_other").on("complete", function() {
jj("form").submit();
});
jj("#flash_uploader_other").plupload("start");
}
});
});
请帮忙
谢谢
现在开始工作了
我替换了以下代码
jj("form").submit(function(e) {
// Files in queue upload them first
if (jj("#flash_uploader_other").plupload("getFiles").length > 0) {
// When all files are uploaded submit form
jj("#flash_uploader_other").on("complete", function() {
jj("form").submit();
});
jj("#flash_uploader_other").plupload("start");
}
});
使用此代码:
jj("form").submit(function(e) {
var uploader = jj("#flash_uploader_other").plupload("getUploader");
// Validate number of uploaded files
if (uploader.total.uploaded == 0) {
// Files in queue upload them first
if (uploader.files.length > 0) {
// When all files are uploaded submit form
uploader.bind("UploadProgress", function() {
jj("#flash_uploader_other").on("complete", function() {
jj("form").submit();
});
});
jj("#flash_uploader_other").plupload("start");
} else {
jj("form").submit();
}
//alert('You must at least upload one file.');
e.preventDefault();
}
});
啊,终于起作用了:)