class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
I can upload images fine, but for some reason not mp3s. I get an "error: Incorrect type of file" message. My php.ini file allows a max size of 10MB and the mp3 I try to upload is only 2MB.
Here is what I have:
$fileMP3 = new upload($_FILES['file_mp3']);
if ($fileMP3->uploaded) {
$fileMP3->allowed = array('audio/mp3','audio/wma');
$fileMP3->process('/home/mydir/public_html/uploads/');
}
if ($fileMP3->processed) {
echo 'Success';
$fileMP3->clean();
exit;
} else {
echo 'error : ' . $fileMP3->error;
exit;
}
where file_mp3 is the name of my form field. I assume the answer lies in the allowed mime-type but this seems to be correct. Is there something else I'm missing?
After more troubleshooting I noticed whenever I add a $handle->allowed, I get the same error (no matter what the mime-type is). I only seem to be able to upload images without having to use $handle->allowed.Reply
I had the same problem. The source of this problem is that my MP3 files were being found to have MIME = application/octetstream. The solution above worked for me.
Here is what I have:
where file_mp3 is the name of my form field. I assume the answer lies in the allowed mime-type but this seems to be correct. Is there something else I'm missing?
Thanks,
Roger
As for allowed, use it as following, to test:
Thank you