I'm using $_FILES['Filedata']['type']
to get the file type, but it is giving "application/octet-stream"
for every file I upload (i.e, .jpg / .pdf / .txt etc).
Can any one help me for this?
<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>
$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';
}
}
Thanks for any help.
Since you have input file which have name "file_upload
", so try to change $_FILES['Filedata']['type']
to $_FILES['file_upload']['type']
because the first index should be the name of object.