我$_FILES['Filedata']['type']
用来获取文件类型,但它为"application/octet-stream"
我上传的每个文件(即 .jpg / .pdf / .txt 等)提供。
任何人都可以帮助我吗?
<form>
<div id="queue"></div>
<input id="file_upload" name="file_upload" type="file" multiple="true">
</form>
<script type="text/javascript">
$(function() {
$('#file_upload').uploadify({
'auto' :true,
'multi':true,
'swf' : 'uploadify.swf',
'uploader' : 'uploadify.php',
'method' : 'post',
'formData':{'token':'xyz'},
'onUploadSuccess' : function(file, data, response) {
alert(data); }
});
});
</script>
上传.php
$targetFolder = 'uploads';
$verifyToken = $_POST['token'];
if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
echo $_FILES['Filedata']['type'];
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $targetFolder;
$targetFile = rtrim($targetPath,'/').'/'.$_FILES['Filedata']['name'];
if (move_uploaded_file($tempFile,$targetFile)) {
echo 'Copied successfully';
}
}
谢谢你的帮助。