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;
}
}
Asked
Active
Viewed 4,563 times
3

Martin Prikryl
- 188,800
- 56
- 490
- 992

sidhesh
- 107
- 2
- 5
-
use this mime for mp3: audio/mpeg – Feb 07 '13 at 06:16
-
The ["type"] value is provided by the browser: it could be forged, wrong, or even missing. DO NOT TRUST IT! – CAFxX Feb 07 '13 at 06:19
3 Answers
2
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.

Community
- 1
- 1
0
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.

web-nomad
- 6,003
- 3
- 34
- 49
-
Sorry for no explaining it clearly,but what i actually mean was i want to upload only .wav & .mp3 file,using the code above which i gave,.wav files gets esaily uploaded but .mp3 file dont get uploaded.. – sidhesh Feb 07 '13 at 06:18
0
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

Mevin Babu
- 2,405
- 21
- 34