September 3, 201313 yr Hey, I have created a website and on one of the pages you can listen to music my friends have made. I want to make these tracks downloadable. How do I make mp3 files downloadable? Cheers
September 3, 201313 yr make a file called dl.php <?php $filename = 'path/to/downloads/'.abs(intval($_GET['file'])).'.mp3'; if (file_exists($filename)) { header("Content-Length: ".filesize($filename)); header('Content-Type: audio/mp3'); header('Content-Disposition: attachment; filename=audiofile.mp3'); readfile($filename); } ?>then just name the files 1.mp3, 2.mp3 etc... or you can use a database to stoe the path/name etc ...
September 3, 201313 yr Except, please don't start a filename with a number like 1.mp3, always use a letter character like a1.mp3, a2.mp3, etc. http://webdesign.about.com/od/beginningtutorials/f/html-file-names.htm Edited September 3, 201313 yr by Wickham
September 7, 201313 yr There is an easy way I think everybody can do, that is, you can compress the MP3 file to make it as a ZIP file and then upload the ZIP file to your server. When a user click the link for the ZIP file, the web browser will remind he or she whether to download the ZIP file or not. That's it.Hope it will be useful to you.
Create an account or sign in to comment