Jump to content

Download mp3 file in php


karthikvasan

Recommended Posts

Hi,

 

i done php code for download mp3 file and its working perfectly. but the issues is when i download the mp3 file the tags (artist, album,...) are not copied from sourcefile.

 

my code is:

 

 

            header('Content-type: audio/mpeg');

header('Content-length: ' . filesize($songlistpath[$ival]));

header('Content-Disposition: filename="'.$songlistpath[$ival].'"');

header('X-Pad: avoid browser bug');

header('Cache-Control: no-cache');

print file_get_contents($songlistpath[$ival]);

 

i set tags (Title , subtitle, rating,comments,album,artist, genre, length, name, type) in source mp3 file. but after download that  file, these tags are not available in the new mp3 file (downloaded file) .

 

how can i solve it.

 

thank you

 

By

 

Karthik

Link to comment
Share on other sites

Hi,

 

opz sorry for that. here after i wont do this mistake.

 

coming to my issue.

 

im sure that tags are part of the mp3 file not stored in outside. when i download the same file through filezilla the tags are perfectly available in that file.

 

 

By

 

Karthik

Link to comment
Share on other sites

Are you sure you are downloading the file? If your browser has a default mp3 player it will play that file - not download it. At least that is my experience using two different browsers with that script. Each browser used a different app to play the file. So, it could be something to do with the browser you are using and how it is configured to handle mp3 files or the default player. If you are wanting to download the file, then you should force the file to download instead of using the default handler for mp3 files as configured in your browser. Just do a search for "PHP force download" and I'm sure you find plenty of scripts.

 

Otherwise, if your intention is to play the mp3 file directly from the browser then you should look at setting a different default player in your browser.

Link to comment
Share on other sites

thank u Psycho.

 

i can download the mp3 file through my php script. and sure that the mp3 file not playing on browser, i just keep this script only for download. its working fine. the only thing is the properties/tags of the mp3 file. i dont know why the original tags of the files are removed after download it. i want to keep the tags for source mp3 file in the downloaded file.

 

Ex: Title , subtitle, rating,comments,album,artist, genre, length, name, type and etc... these tags are available in source mp3 file. but after download it through php the tags are removed. i dont know how to rectify it.

 

By

Karthik

 

 

 

Link to comment
Share on other sites

thank u Psycho.

 

i can download the mp3 file through my php script. and sure that the mp3 file not playing on browser, i just keep this script only for download. its working fine. the only thing is the properties/tags of the mp3 file. i dont know why the original tags of the files are removed after download it. i want to keep the tags for source mp3 file in the downloaded file.

 

Ex: Title , subtitle, rating,comments,album,artist, genre, length, name, type and etc... these tags are available in source mp3 file. but after download it through php the tags are removed. i dont know how to rectify it.

 

You're not going to get anywhere by repeating the same thing you stated before. I don't think you really read my post and understood it. I ran your script with an MP3 file and in IE and FF the file was played using two different players (and the tags were displayed). This tells me that with that script the browser is determining what to do with the file. So, if your browser is downloading the file as opposed to playing it - the browser might be using some alternative download method that is stripping out the tags.

 

As I stated before you should try using a method that does a force download. If the problem is due to some alternative download method then this could solve the problem.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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