我正在使用Plupload與PHP,我的代碼如下。Plupload問題 - 文件正在上傳{Filename} .part&FileUploadedevent未被觸發
我的問題
問題1 ::文件被上傳。部分,但在文件名的末尾添加。進度條顯示100%。
問題2 :: FileUploaded事件未觸發。
<script type="text/javascript">
// Custom example logic
var uploader = new plupload.Uploader({
runtimes : 'html5,flash',
browse_button : 'pickfiles', // you can pass in id...
container: document.getElementById('container'), // ... or DOM Element itself
url : 'upload.php',
flash_swf_url : 'js/upscript/Moxie.swf',
silverlight_xap_url : 'js/upscript/Moxie.xap',
multiple_queues : false,
multi_selection : false,
multipart_params : {folder:'lbs'},
filters : {
max_file_size : '10mb',
mime_types: [
{title : "Video files", extensions : "<?php echo implode(",",$allowed_files)?>"}
]
},
init: {
PostInit: function() {
document.getElementById('filelist').innerHTML = '';
document.getElementById('uploadfiles').onclick = function() {
uploader.start();
return false;
};
},
FilesAdded: function(up, files) {
plupload.each(files, function(file) {
document.getElementById('filelist').innerHTML += '<div id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></div>';
});
},
UploadProgress: function(up, file) {
document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
},
Error: function(up, err) {
document.getElementById('console').innerHTML = "\nError #" + err.code + ": " + err.message;
},
FileUploaded: function(up, file, info) {
console.log(info);
var response = jQuery.parseJSON(info.response);
if(response.st == "ok")
{
window.location.href = window.location.href.replace('?saved','') + '?saved';
}
//document.getElementById('console').innerHTML = "\nError #" + response.error.code + ": " + response.error.message;
}
}
});
uploader.init();
</script>
請提出建議。
我錯過了提到這段代碼與我的本地WAMP服務器正常工作,但在現場Web服務器上存在問題。 –
似乎是一個服務器端問題。如果您使用示例中的upload.php,則您所描述的內容似乎與最後6行未執行的事實一致https://github.com/moxiecode/plupload/blob/master/examples/upload.php# L119 – jbl