0

Hi frnds...


i m trying to upload mp3 file ..this is my code..

upload_max_filesize = 20M;//in php.ini

$tname = $_FILES["tphoto"]["name"];
$ttmp_name = $_FILES["tphoto"]["tmp_name"];

 //Audio File Uploading....  
 if($_FILES['tphoto']['type'] == 'audio/mpeg'){
 $dir="../../music/$aid";
 move_uploaded_file($ttmp_name,"$dir"."/"."$tname");
 }

it displays no error...but, no output.

can any body give me some suggestion plz...

Thanks in advance...
Sari K

3
Contributors
40
Replies
42
Views
7 Years
Discussion Span
Last Post by abhicool1
0

check if this is in your form -
enctype="multipart/form-data"

Hi ,

Thanks 4 ur reply...

it works fine for all (images, WMA)....when i change the below code..

$_FILES['tphoto']['type'] == 'audio/wma'

....


prob only for MP3 files...

0

if you check against that type only, its obvious that script will allow only that file type.
Maybe you are looking for "audio/x-mpeg-3" as file type.

0

if you check against that type only, its obvious that script will allow only that file type.
Maybe you are looking for "audio/x-mpeg-3" as file type.

hi

file type= "MP3 formate sound";

//file type ..

i need to allow only MP3 FILES.....

Is there any other parameters change in PHP.INI??...

0

then why you not using straightaway
$_FILES["file"]["type"] == "audio/mp3";

Hi ..

I m sorry....

when i m write the if condition..its not working for all types..

if (($_FILES["tphoto"]["type"] == "audio/wma")){

with out condition it works fine except for MP3....

0

By using this "if loop " , you actually what is the file type, and if the file type is the specified one then allow the process else do something else.
I think why to use it, must be clear to you by this now.
And you saying when you not using this if loop you are able to upload all the files except the MP3, maybe with this MP3 file you are violating the file size limit.
echo your file element and post it's contents here with this file

0

Hi ..


now i m trying for 5 mb MP3 file...its uploaded perfectly....So, the prob with file size...but in my php.ini

upload_max_size=20M

plz tell me wat i have to do...

Thanks a lot..

Edited by sarithak: n/a

0

try with another mp3 file having small size and post your entire code here.
and you seem to be confused, first decide which file types you want to restrict and which file types you want to allow.accordingly we will proceed with the code.

0

try with another mp3 file having small size and post your entire code here.
and you seem to be confused, first decide which file types you want to restrict and which file types you want to allow.accordingly we will proceed with the code.

hi...

this is my code...its working fine for all(including MP3)...but upto 5MB files only uploaded..8,9,11MB files are not uploaded..

$aid =  mysql_real_escape_string($_POST['albumname']);
$song =  mysql_real_escape_string($_POST['song']);
$singers =  mysql_real_escape_string($_POST['singers']);
$tname = mysql_real_escape_string($_FILES["tphoto"]["name"]);
$ttmp_name = $_FILES["tphoto"]["tmp_name"];

 //Audio File Uploading....  
//if (($_FILES["tphoto"]["type"] == "*.MP3")){ //not working when i use if condition..
 $dir="../../music/$aid";
 move_uploaded_file($ttmp_name,"$dir"."/"."$tname");
 

$sql="insert into music_songs values('','$aid','$song','$singers','$tname')";
$res=mysql_query($sql)or die(mysql_error());
 
//}

another one...now i m working on localhost....

0

is "audio/mp3" and "MP3" same for you ?

HI..

this is not same....by mistake i put the code as ( *.MP3)... basically i checked for (audio/mp3)...its not working when i put condition there...not only for MP3...
its not working for all types of files when i use if conditon..k...also plz tell me how can i solve the MAX SIZE problem ..

0

Again you seem to be confused.This time you are having problem with all the file types.
The max size can be set in the php.ini as, search for "upload_max_filesize" .It may have default value of 2MB at the moment edit it to have whatever you like.

0

Again you seem to be confused.This time you are having problem with all the file types.
The max size can be set in the php.ini as, search for "upload_max_filesize" .It may have default value of 2MB at the moment edit it to have whatever you like.

Hi Network18,

You r correct..at that time it takes all types of files...k leave it...


I am having doubt on "upload_max_filesize" ..how can i change the values in php.ini file(which is located in server)...plz tell me is there any way to do by using coding????

i think this is stupid question, but no chance to me...


Thanks in advance..

0

Hi Network18,

You r correct..at that time it takes all types of files...k leave it...


I am having doubt on "upload_max_filesize" ..how can i change the values in php.ini file(which is located in server)...plz tell me is there any way to do by using coding????

i think this is stupid question, but no chance to me...


Thanks in advance..

Yes, you can do that by function ini_set()-

//This is your new size
$new_size = '3M';
ini_set('upload_max_filesize',$new_size);

most of the properties in the php.ini can be set during runtime using ini_set() function.The new values last there till the script executes.
And don't worry, nothing is stupid, until you don't know it:)
its always good to clarify the doubts here.

0

Yes, you can do that by function ini_set()-

//This is your new size
$new_size = '3M';
ini_set('upload_max_filesize',$new_size);

most of the properties in the php.ini can be set during runtime using ini_set() function.The new values last there till the script executes.
And don't worry, nothing is stupid, until you don't know it:)
its always good to clarify the doubts here.

Hey...

Thanks to all....once again thanks a lot...keep it up...

0

hi sir,

This time i m getting warning

PHP Warning: POST Content-Length of 9484737 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

i fixed the


$new_size = '20M';

ini_set('upload_max_filesize',$new_size);

the uploading file size is 9 to 10 MB...

0

hi sir,

This time i m getting warning

i fixed the


$new_size = '20M';

ini_set('upload_max_filesize',$new_size);

the uploading file size is 9 to 10 MB...

Does it solve your problem..you can supress any warning with prefixing '@' to the function like @ini_set(), eventhough i never recommend doing that.

0

Does it solve your problem..you can supress any warning with prefixing '@' to the function like @ini_set(), eventhough i never recommend doing that.

hi sir,,


after fix the @ini_set ,also i m getting the same warning...

0

Does it solve your problem..you can supress any warning with prefixing '@' to the function like @ini_set(), eventhough i never recommend doing that.

hi sir,,


after fix the @ini_set ,also i m getting the same warning...

Is there any other method to upload audio files?..because it takes around 4 to 5 mins...

0

hi sir,,


after fix the @ini_set ,also i m getting the same warning...

Is there any other method to upload audio files?..because it takes around 4 to 5 mins...

very strange actually using @ should suppress warning if any.

0

very strange actually using @ should suppress warning if any.

hi...

somebody help me regarding this warning....

the code runs some time..after some time it display warning...

PHP Warning: POST Content-Length of 9484737 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

is there any problem with execution time? ...

Thanks in Advance............

0

hi...

somebody help me regarding this warning....

the code runs some time..after some time it display warning...

is there any problem with execution time? ...

Thanks in Advance............

since you carrying the lots of data in post, your default value of '8Mb' for "post_max_value" is exceeded.
So you need to set this variable to the higher value too, in the similar way i told you set the max_file_upload.

$new_limit = '10Mb';
ini_set('post_max_value',$new_limit);
0

since you carrying the lots of data in post, your default value of '8Mb' for "post_max_value" is exceeded.
So you need to set this variable to the higher value too, in the similar way i told you set the max_file_upload.

$new_limit = '10Mb';
ini_set('post_max_value',$new_limit);

Hi,
still i m getting the same warning....

0

Hi,
still i m getting the same warning....

are you using the $new_limit variable more than once.
post your code , to what value you setting those variables now

0

are you using the $new_limit variable more than once.
post your code , to what value you setting those variables now

Hi

this is my code...

error_reporting(E_ALL^E_NOTICE);
 $new_size = '50M';
@ini_set('upload_max_filesize',$new_size);
 $new_limit = '20Mb';
 @ini_set('post_max_value',$new_limit);
0

Hi

this is my code...

error_reporting(E_ALL^E_NOTICE);
 $new_size = '50M';
@ini_set('upload_max_filesize',$new_size);
 $new_limit = '20Mb';
 @ini_set('post_max_value',$new_limit);

If the warning as below -

PHP Warning: POST Content-Length of 9484737 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

it mentions that your post carries 9484737 bytes i.e. 9.04535MB of data.So setting new_limit to the 50MB is still not enough.
Increase it to fare enough as -

$new_limit = '100M';
0

If the warning as below -

PHP Warning: POST Content-Length of 9484737 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

it mentions that your post carries 9484737 bytes i.e. 9.04535MB of data.So setting new_limit to the 50MB is still not enough.
Increase it to fare enough as -

$new_limit = '100M';

HI Sir,


this is my code...still i got the same warning....i tried to upload 7.9 MB..its uploaded...but for 8.3 MB..its not working...

$new_size = '100M';
 $new_limit = '100M';
 @ini_set('post_max_value',$new_limit);
@ini_set('upload_max_filesize',$new_size);

i saw in many sites(tutorials)...every where having same asnwer wat u told....dont know wat to do...any other way????

Thanks in advance...

Edited by sarithak: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.