Jump to content

mp3 uploader not working!!


vin_akleh

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/197161-mp3-uploader-not-working/
Share on other sites

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.

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.

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

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).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.