Reputation: 107
if ((($_FILES["myfile"]["type"] == "audio/mp3") ||
($_FILES["myfile"]["type"] == "audio/wav")) &&
($_FILES["myfile"]["size"] < 20000000))
{
if (move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path) )
{
$result1=1;
}
}
Upvotes: 3
Views: 4638
Reputation: 2475
You can check by evaluating the extension of the uploaded file or if you want to check file level then you can one of the pear packages https://pear.php.net/package/MP3_ID
Upvotes: 0
Reputation: 6003
Two things.
Check the size of your .mp3
file.
Check the file type of your .mp3
if it is actually audio/mp3
. Try print_r($_FILES);
.
$type = $_FILES["myfile"]["type"];
$size = $_FILES["myfile"]["size"];
if( ( ($type == "audio/mp3") || ($type == "audio/wav") ) && ($size < 20000000)) {
if(move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path) ) {
$result1=1;
}
}
Hope it helps.
Upvotes: 0
Reputation:
just print $_FILES["myfile"]["type"];
for real mp3 file then copy the value and use it instead of audio/mp3 because MIME type of mp3 will not be 'audio/mp3', i think its audio/mpeg
Please check this Link also, because its not recommended to depend on $_FILES["myfile"]["type"]
that send by browser.
Upvotes: 2