vin_akleh Posted March 31, 2010 Share Posted March 31, 2010 this code works file on images, pdf and shortcut files but not mp3!!! why?? any one knows <html> <body> <form action="" method="POST" enctype="multipart/form-data"> Browse file to upload <input type="file" name="filetoupload" id="filetoupload"><br/> <input type="submit" name="sb" id="sb" value="Upload now"> </form> <?php if(isset($_POST['sb'])) { $path = "images"; $file = $_FILES['filetoupload']['name']; move_uploaded_file($_FILES['filetoupload']['tmp_name'], "$path/$file"); } ?> </html> </body> thanks in advanced Quote Link to comment Share on other sites More sharing options...
the182guy Posted March 31, 2010 Share Posted March 31, 2010 Are you getting any error messages? Or blank page? I'd guess you're getting a fatal error but it's not being shown because display errors is set to off. I think the fatal error is the default 30 second timeout, and the MP3 file your testing is too large to upload in 30 seconds so the fatal error is thrown. If that is the case, use set_time_limit(300) to change the timeout so that the script won't timeout so soon. The argument of that function is the number of seconds, e.g. 300 = 5min. Quote Link to comment Share on other sites More sharing options...
vin_akleh Posted March 31, 2010 Author Share Posted March 31, 2010 if that is what you mean <?php //i have tried it here 2 "set_time_limit(300);" if(isset($_POST['sb'])) { set_time_limit(300); $path = "images"; $file = $_FILES['filetoupload']['name']; move_uploaded_file($_FILES['filetoupload']['tmp_name'], "$path/$file"); } ?> that didnt work and yes it gives no errors when i upload a pdf file it takes some seconds to reload the page (after upload), but when i try to upload an mp3 it takes smaller time to reload the page. Quote Link to comment Share on other sites More sharing options...
the182guy Posted March 31, 2010 Share Posted March 31, 2010 It could be that your host is rejecting the MP3 file. Are you using a webhost or is this on your local development machine? Try adding this inside the if statementt, it should print out details about the uploaded file. print_r($_FILES); Quote Link to comment Share on other sites More sharing options...
vin_akleh Posted March 31, 2010 Author Share Posted March 31, 2010 i am using WAMPSERVER. this is the output of "print_r($_FILES);": Array ( [filetoupload] => Array ( [name] => Open My Eyes (acoustic).mp3 [type] => [tmp_name] => [error] => 1 => 0 ) ) what is the "[error] => 1"??! Quote Link to comment Share on other sites More sharing options...
the182guy Posted March 31, 2010 Share Posted March 31, 2010 Error code 1 means your PHP configuration is set to not allow this upload because it exceeds the maximum. You need to change these settings either in your php.ini ; Maximum allowed size for uploaded files. upload_max_filesize = 50M ; Maximum size of POST data that PHP will accept. post_max_size = 50M Quote Link to comment Share on other sites More sharing options...
ignace Posted March 31, 2010 Share Posted March 31, 2010 UPLOAD_ERR_INI_SIZE Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini. Reading the manual truly helps http://www.php.net/manual/en/features.file-upload.errors.php Quote Link to comment Share on other sites More sharing options...
vin_akleh Posted March 31, 2010 Author Share Posted March 31, 2010 i did modify php.ini restarted my PC didn't work!! Array ( [filetoupload] => Array ( [name] => Doumk La 2lby.mp3 [type] => [tmp_name] => [error] => 1 => 0 ) ) any other suggestions? Quote Link to comment Share on other sites More sharing options...
the182guy Posted March 31, 2010 Share Posted March 31, 2010 i did modify php.ini restarted my PC didn't work!! Array ( [filetoupload] => Array ( [name] => Doumk La 2lby.mp3 [type] => [tmp_name] => [error] => 1 => 0 ) ) any other suggestions? Check that you have modified the correct php.ini. Sometimes those all in one installations litter several php.ini files around. You can check you've modified the correct one by creating and running a page with this code phpinfo(); It will display your PHP configuration on the page, look for the settings upload_max_filesize and post_max_size and make sure they are set as they should be (enough to cover the MP3 file). 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.