Uploading mp3 files

See all posts Reply

Uploading mp3 files new!
by Roger, 16 years, 5 months ago
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?

Thanks,
RogerReply
Re: Uploading mp3 files new!
by colin, 16 years, 5 months ago
What says the log of the class?Reply
Re: Uploading mp3 files new!
by Roger, 16 years, 5 months ago
Do you mean the error_log file? It doesn't list anything regarding this error.Reply
Re: Uploading mp3 files new!
by Roger, 16 years, 5 months ago
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
Re: Uploading mp3 files new!
by colin, 16 years, 5 months ago
You can copy here the log of the class, which gives information regarding the MIME types:
echo $fileMP3->log;

As for allowed, use it as following, to test:
$handle->allowed = array('*/*');
$handle->forbidden = array('');
Reply
Re: Uploading mp3 files new!
by Claudiu Hojda, 16 years, 4 months ago
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.

Thank youReply