Guy
10-21-07, 01:23 PM
I'm am currently starting to work on a cms for a client, the client needs to be able to upload MP3 files to a folder and add nodes to a xml file for this to work correctly, Im starting this with the upload.
The coding below if what I currently have:
This is the standard HTML
<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
This is the PHP
<?php
if (($_FILES["file"]["type"] == "audio/mpeg")
||($_FILES["file"]["type"]=="audio/x-mpeg")
||($_FILES["file"]["type"]=="audio/x-mpeg-3")
||($_FILES["files"]["type"]=="audio/mpeg3")
)
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1000024) . " M<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("tracks/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"tracks/" . $_FILES["file"]["name"]);
echo "Stored in: " . "tracks/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file <br />";
}
?>
This all works fine as long as the mp3 is at a bit rate below 100, (it will upload any mp3 with a bit rate of 32 64 96 ect..)
but if I try to upload a mp3 with a bit rate of 128 I get the Invalid File echo.
Is there another mime type that I have not included??
or is there something that I need to configure in the PHP.ini file
I am working with these locally (on my computer) until I get it work correctly
these are the current setting on my php.ini
the largest file I have tried to upload with this code is 4.5 m
file_uploads = On
upload_tmp_dir = "C:\Program Files\xampp\tmp"
upload_max_filesize = 32M
Thanks in advance
The coding below if what I currently have:
This is the standard HTML
<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
This is the PHP
<?php
if (($_FILES["file"]["type"] == "audio/mpeg")
||($_FILES["file"]["type"]=="audio/x-mpeg")
||($_FILES["file"]["type"]=="audio/x-mpeg-3")
||($_FILES["files"]["type"]=="audio/mpeg3")
)
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1000024) . " M<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("tracks/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"tracks/" . $_FILES["file"]["name"]);
echo "Stored in: " . "tracks/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file <br />";
}
?>
This all works fine as long as the mp3 is at a bit rate below 100, (it will upload any mp3 with a bit rate of 32 64 96 ect..)
but if I try to upload a mp3 with a bit rate of 128 I get the Invalid File echo.
Is there another mime type that I have not included??
or is there something that I need to configure in the PHP.ini file
I am working with these locally (on my computer) until I get it work correctly
these are the current setting on my php.ini
the largest file I have tried to upload with this code is 4.5 m
file_uploads = On
upload_tmp_dir = "C:\Program Files\xampp\tmp"
upload_max_filesize = 32M
Thanks in advance