1 Attachment(s)
need help with small php upload file script
if you have apache please try to get this script to upload mp3 files. it keeps saying invalid file what ever i do.
PHP Code:
<?php
if (($_FILES["file"]["type"] == "audio/x-ms-wma")
|| ($_FILES["file"]["type"] == "audio/mp3")
&& ($_FILES["file"]["size"] < 20000000000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
Re: need help with small php upload file script
my server running apache 2.2.4 with php 5.2.1 uploaded it fine. the mp3 file was 2.68mb in size and was named "2pac - last battle.mp3". script was completely unaltered, although i removed the index.html file. also added a "max_file_size" property to index.php's code.
try it for yourself
Re: need help with small php upload file script
Quote:
Originally Posted by kows
my server running apache 2.2.4 with php 5.2.1 uploaded it fine. the mp3 file was 2.68mb in size and was named "2pac - last battle.mp3". script was completely unaltered, although i removed the index.html file. also added a "max_file_size" property to index.php's code.
try it for yourself
it still says the same thing for me :/
Re: need help with small php upload file script
when you run the script on MY webserver? if that's so, then something is either wrong with your browser -- or maybe something to do with the file you're uploading. so, what browser are you using, and what type of file did you try to upload? how large was it? have you tried different files? does the file have the "mp3" file extension? have you tried using the stand-alone function mime_content_type() to find out what content-type it is returning on its own? (if you try this and get an error stating that the function does not exist, you'll need to enable the use of mime_magic in your PHP ini by changing mime_magic.debug to 1 or On and also verify that mime_magic.magicfile is a valid path to the mime_magic file in your PHP directory).
if it just isn't working on your webserver; I assume you're using apache, but what version? and what version of php are you using? do you have file uploads enabled in your PHP ini file? is the file larger than the maximum allowed filesize that your PHP ini has set? any custom apache configuration that might have some adverse affect on the script? you might also want to check what mime type the file is returning via the instructions above in this case, too.
edit: added a few things.