Jump to content

Recommended Posts

Ok, I have an MP3 Upload site, but when a user logs in and uploads a file, more than half of the time the MP3's MIME type returns absolutely nothing!

 

I don't think it's the code, because some of the music uploads well, it's just about 65% has no MIME! Any explanation?

Link to comment
https://forums.phpfreaks.com/topic/56606-_filesfiletype-returns-nothing/
Share on other sites

First off, check to make sure you didn't misspell anything.

 

From the PHP Manual

The mime type of the file, if the browser provided this information. An example would be "image/gif". This mime type is however not checked on the PHP side and therefore don't take its value for granted.

 

This means that the browser send the type. Some browsers don't send them. Try using a different browser.

 

Type will be empty if there is an error uploading the file. Check the value of $_FILES['X']['error'] to make sure that everything is all good. See http://www.php.net/manual/en/features.file-upload.errors.php if there is an error.

 

If none of the above, you'll need to post your code here so we can see it.

function Query() {
if($_FILES['File']['size'] <= 500000) {
	echo 'File Size Ok. ' . $_FILES['File']['size'] . '<br />';
} else {
	echo 'File Too Big!<br />';
}
$MIME = array('audio/mpeg', 'audio/mp3');
if(in_array($_FILES['File']['type'], $MIME)) {
	echo 'File Type Ok.<br />';
} else {
	echo 'File Isn\'t MP3 Format: ' . $_FILES['File']['type'] . '<br />';
	echo 'Temp File Stored As: ' . $_FILES['File']['tmp_name'] . '<br />';
}
if(move_uploaded_file($_FILES['File']['tmp_name'], 'Music/' . mysql_insert_id() . '.mp3')) {
	echo 'Success!';
} else {
	echo 'Error!';
}
}

Only some MP3's uploaded.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.