i’m trying upload image and mp3 in the same form but image is uploaded and mp3 is not.
this is my form
<form action="upload.php"
enctype="multipart/form-data" method="post">
<p>
Please select image<br>
<input type="file" name="image" size="40">
</p>
<p>
Please select audio<br>
<input type="file" name="audio" size="40">
</p>
and this is my upload.php
// checking image
if (($_FILES["image"]["type"] == "image/gif")
or ($_FILES["image"]["type"] == "image/jpeg")
or ($_FILES["image"]["type"] == "image/pjpeg")
or ($_FILES["image"]["type"] == "image/png"))
{
if ($_FILES["image"]["error"] == 0)
{
move_uploaded_file($_FILES["image"]["tmp_name"],
"upload/".$_FILES["image"]["name"]);
}
else
{
echo "image upload failed";
}
}
else
{
echo "file is not supported image";
}
// checking mp3
if (substr($_FILES["audio"]["name"],-3) == "mp3")
{
if ($_FILES["audio"]["error"] == 0)
{
move_uploaded_file($_FILES["audio"]["tmp_name"],
"upload/".$_FILES["audio"]["name"]);
}
else
{
echo "audio upload failed";
}
}
else
{
echo "file is not supported audio";
}
now, image get’s uploaded and moved to ./upload but on mp3 it echoes “audio upload failed”.
Don’t get it
Your code correct for your work just check your
upload_max_filesize on your php.ini
default upload size limit 2mb chage it.