我想使用uploadify最新版本上传视频,但我失败了。
我的代码:
HTML:
<form enctype="multipart/form-data" class="form-part" action="form.php" method="post">
<input class="uplodify" id="file_upload" type="file"/>
</form>
jQuery:
$('#file_upload').uploadify({
swf: 'uploadify/uploadify.swf',
uploader: 'uploadify/uploadify.php',
multi: true,
//queueSizeLimit: 3,
fileExt: '*.jpg;*.gif;*.png;*.mp4;*.mp3;*.avi;*.wmv;*.flv;',
auto: true,
onUploadStart: function(file) {
console.log(file);
},
onUploadComplete: function(event, ID, fileObj, response, data) {
},
onUploadError : function(file, errorCode, errorMsg, errorString) {
alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
},
onUploadSuccess : function(file, data, response) {
console.log('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
}
});
PHP:
error_reporting(0);
$targetFolder = '/uploads'; // Relative to the root
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = dirname(dirname(__FILE__)) . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png', 'mp3', 'mp4', 'avi', 'flv', 'wmv'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo '1';
} else {
echo 'Invalid file type.';
}
}
注意:没有错误console
onUploadSuccess()
日志为:文件 easyhtm-wp.FLV 已成功上传,响应为 true:文件类型无效。
就在此行之后,控制台中显示的警告如下:
请帮我解决一下这个。
谢谢。