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

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

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

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.

a

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

a

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

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

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

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

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.

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

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

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

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.

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

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.

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

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

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.

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

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

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.

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

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

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

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

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

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';

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.