Jump to content

Downloading Music Files: Where do I Start?


Trium918

Recommended Posts

I've search google and found bit and pieces of code, but unfortunately my head is still cloudy. I am looking for someone to point me in the right direction. I am going to attempt to write a php script that will allow the user to download free music such http://www.livemixtapes.com which is using php as well. I am looking for functions, headers, and whatever else I  would need to complete this task of mines. How to step up structure of the <dir> etc... Thanks.

Link to comment
Share on other sites

So you are basically creating an e-commerce site where users add music files to their cart and can download them once they have paid for them. Am I correct? If so, have a look at osCommerce. This is an e-commerce script that has file download functionality. http://www.oscommerce.com/

You can study and re-create the parts you need for your own site. This is too big a project to give a simple answer to. You need to break the project into smaller parts before asking for help.

Link to comment
Share on other sites

So you are basically creating an e-commerce site where users add music files to their cart and can download them once they have paid for them. Am I correct? If so, have a look at osCommerce. This is an e-commerce script that has file download functionality. http://www.oscommerce.com/

You can study and re-create the parts you need for your own site. This is too big a project to give a simple answer to. You need to break the project into smaller parts before asking for help.

So you are basically creating an e-commerce site where users add music files to their cart and can download them once they have paid for them. Am I correct? If so, have a look at osCommerce. This is an e-commerce script that has file download functionality. http://www.oscommerce.com/

You can study and re-create the parts you need for your own site. This is too big a project to give a simple answer to. You need to break the project into smaller parts before asking for help.

 

No mixtapes are free. http://livemixtapes.com

Link to comment
Share on other sites

Ok, just store the music files in a directory that is outside of your document root i.e

 

/music/

/public_html/

 

When a member clicks on the file that they want to download use a header to prompt a download i.e

 

$filename = "/music/file.mp3";

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Length: ".filesize($filename));
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$filename);
readfile($filename)

 

Have a look at the php manual

http://php.net/manual/en/function.header.php

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.