prankstar008 Posted December 2, 2007 Share Posted December 2, 2007 The short version of my story is that I am trying to make a website where you can upload mp3 files. Yes, I have permission to use the files that will be uploaded. My problem is that the files don't upload. I think I have confirmed that the issue is the file size as I can upload smaller files of all types. I have changed my php.ini file to look like this ;;;;;;;;;;;;;;;; ; File Uploads ; ;;;;;;;;;;;;;;;; ; Whether to allow HTTP file uploads. file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). ;upload_tmp_dir = ; Maximum allowed size for uploaded files. upload_max_filesize = 20M my php file that handles uploads looks like this <?php $filename = $_FILES["theSong"]["name"]; $extension = substr($filename, strpos($filename,"."), strlen($filename)); /* if ($extension != ".mp3" || $_FILES["theSong"]["size"] > 7000000){ echo "<script type = 'text/javascript'> alert('ERROR: File must be an mp3 and smaller than 7MB'); </script>"; } else{ */ move_uploaded_file($_FILES["theSong"]["tmp_name"], "upload/" . $_FILES["theSong"]["name"]); echo "Error: " . $_FILES["file"]["error"]; //} ?> *****NOTE that the check for size and type are currently commented out!!!!***** For the reccord, the file typed that I have had success with were .pdf and .jpg Specs: Apache2 PHP5 Ubuntu Linux Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted December 2, 2007 Share Posted December 2, 2007 and what error do you get? perhaps define a FULL path to where the file is moved to and ensure that directory has teh correct permissions.. Quote Link to comment Share on other sites More sharing options...
prankstar008 Posted December 2, 2007 Author Share Posted December 2, 2007 I get no error. That little snippet was there just to make sure. The path shouldn't matter cause other file types and sizes work. I have set rw permissions on the upload/ folder ("sudo chmod a+rw") Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted December 2, 2007 Share Posted December 2, 2007 the path you specify will be relative to the current running script rather than your site root - which is why I always set a docroot constant to use thought the site so that I know which dir I am working with... Quote Link to comment Share on other sites More sharing options...
prankstar008 Posted December 2, 2007 Author Share Posted December 2, 2007 Ok thanks. I'll change it for good measure, but it isn't going to solve my problem because the realitive path is indeed correct. I have verified this by being able to upload smaller files. Thanks for the quick response though. Quote Link to comment Share on other sites More sharing options...
mr_mind Posted December 2, 2007 Share Posted December 2, 2007 Try this code: <?php $filename = $_FILES["theSong"]["name"]; if ($FILES['theSong']['type']=="audio/mpeg") { if($_FILES['theSong']['size'] > 7000000){ move_uploaded_file($_FILES["theSong"]["tmp_name"], "upload/" . $_FILES["theSong"]["name"]); if($_FILES["theSong"]["error"]==0) [ print 'You have successfully uploaded ' . $_FILES["theSong"]["name"]; } else { print "<script type = 'text/javascript'>" . $_FILES["theSong"]["error"] . "</script>"; } } else { print "<script type = 'text/javascript'>alert('ERROR: File smaller than 7MB')</script>"; } } else { print "<script type = 'text/javascript'>alert('ERROR: File must be an mp3 file')</script>"; } ?> I have added in some better error checking and telling the user the exact problme. And maybe you should try uping the file size because i doubt you could get a 7mb mp3 file even though it is compressed Quote Link to comment Share on other sites More sharing options...
prankstar008 Posted December 2, 2007 Author Share Posted December 2, 2007 I get error 2.... know anything bout that? I'm googling it. Thanks a lot. Quote Link to comment Share on other sites More sharing options...
mr_mind Posted December 2, 2007 Share Posted December 2, 2007 well for one thing. i changed the error checking mechanism use were using ($_FILES["file"]["error"]) so that it would actually show you anything by changing file to theSong and i did a better filetype checking. What eror did you get exactly and what is the website that this is on? Quote Link to comment Share on other sites More sharing options...
prankstar008 Posted December 2, 2007 Author Share Posted December 2, 2007 wow I am sorry for wasting your time... The error was in my form that was calling this php file. I had max_upload set to 700,000 instead of 7,000,000. Sorry. Thanks for the help though. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.