PDA

View Full Version : How to make a download link


newbie
06-16-2006, 02:25 PM
I am making a site in which I am putting some songs of myself in wma and mp3 format for visitors to download when they click on the links of the songs. Can someone tell me how I can implement this please?

grant
06-16-2006, 02:34 PM
Well, you have a few options when it comes to audio file handling. You can have it streaming, downloadable, or both. If you want to stream your audio files just follow the steps below.

1. Upload your MP3 to your server

2. Open notepad. write the entire url of the mp3: ie: http://www.myserver.com/mp3s/mysong.mp3 (obviously the full real url of your mp3)

3. Do a 'save as' and call it something but add .m3u on the end of it. eg: mysong.m3u

4. Upload this .m3u file to your server too.

5. This acts as a pointer to your mp3 file and the m3u extension tells it to stream. So in your page you just link to the .m3u file. When people click your link it goes to the m3u which auto redirects and streams the MP3 you pointed it to, in the default player of the users operating system. In my case, realplayer.

The beauty of this is that as the URL is contained in the notepad document no-one can see where the MP3s are to download them.

you can use the exact same technique to stream video and audio in realplayer. Your realplayer file is a .rm - so you create a notepad document with the extension .ram and it functions exactly the same. no need for embedding. just pops up in realplayer.

That's form the knowledge base within Bluehost. If you want to make it purely a download only file you can link to it like you would another page on your site through the use of <a href ="/mymusic/mysong.mp3">. Or where ever you might have the file stored on your site.

silentcollision
06-16-2006, 06:03 PM
You could just .zip the files, and put them up. That instantly sets the download.

Other than that, you could tell people to right click and select "save file as".

dvessel
06-16-2006, 06:55 PM
What silent said. Audio files by default gets played by the users designated audio player/plug-in. It should be possible by changing MIME types to have it treated as a direct download instead of playing.

newbie
06-17-2006, 02:06 AM
Thank you guys for your responses. I tried Grant's solution of giving a direct hyperlink to the song wma file, but when I clicked the link, it didn't ask where to save the file, the way it generally happens. Instead it started saving the file to temporary files folder and started playing it when the download was complete. Any ideas as to how this can be corrected?

grant
06-17-2006, 12:03 PM
Thank you guys for your responses. I tried Grant's solution of giving a direct hyperlink to the song wma file, but when I clicked the link, it didn't ask where to save the file, the way it generally happens. Instead it started saving the file to temporary files folder and started playing it when the download was complete. Any ideas as to how this can be corrected?

Like silentcollision said, you can just put your song(s) into a zip file and that will force the download of the zip file. I had forgotten about direct linking the song will force media player, winamp, quicktime, etc to open it and play it. If you want people to simply download them then do what silentcollision suggested.

newbie
06-18-2006, 12:38 PM
Well the zip method is a way to do it, but it's not that neat. I have seen some sites where they do have this method for mp3 or other file types also. There is some PHP script or something for it. Should someone have it, I'll be thankful if they give it to me.

hlsJeff
06-30-2006, 05:15 PM
The beauty of this is that as the URL is contained in the notepad document no-one can see where the MP3s are to download them.


Does this leave a copy of the mp3 in the temporary internet files? I would like to find a way to avoid leaving the file on the user's computer. Thanks.

grant
06-30-2006, 06:47 PM
Does this leave a copy of the mp3 in the temporary internet files? I would like to find a way to avoid leaving the file on the user's computer. Thanks.

Ya know. I really have no idea on that. :D Let me try something real quick and I'll get back to you on that in an Edit.

Edit: Okay, the only thing I can find that this technique will leave on my machine is the m3u file, not the mp3 file. However, upon opening the m3u file I could easily find the actual mp3 file and download it if I wished to. Apparenty knowledgebase doesn't have it all right.

hlsJeff
06-30-2006, 07:55 PM
Here is the scenerio of how some things are done.

When you download an executable file, you may be asked if you wish to run the program "mid air" or if you wish to save it to your hard drive and you will run it yourself later.

Can an mp3 file be used/played without first (at all) saving it your hard drive?

grant
06-30-2006, 10:02 PM
Can an mp3 file be used/played without first (at all) saving it your hard drive?

Yes, if you go the m3u route like I said above. The only file downloaded in that scenario is the m3u and not the mp3. The m3u file is simply a text document telling the browser where the mp3 is and opens it with whatever player the user has chosen to open those kinds of files. No mp3 dowloadning takes place.

hlsJeff
06-30-2006, 10:12 PM
Thanks. I will give that a try. Sounds good.

hlsJeff
07-02-2006, 03:21 PM
I tried using the m3u method, testing using Internet Explorer 6.0.

I deleted all my temporary internet files.

Then ran the HTML which called the mpu which called the mp3. (From the BlueHost server, not my hard drive)

Then I checked my temporary internet files again.

Now I see the HTML file, which shows the mpu file.
I see the mpu file (which can cause the mp3 to be played) and which also shows the mp3 filename that can be used to download the mp3 file.

And I even see the mp3 file itself.

I wonder what I missed. It seemed to just make matters worse. :confused:

dvessel
07-02-2006, 04:08 PM
The M3U file doesn't change anything because your just adding an inbetween step to get to the mp3 files. It's still handled through the client ends designated player as usual. Some clients will use realplayer, quicktime, whatever.. And they store their files in their own places.

hlsJeff
07-02-2006, 04:45 PM
I guess there is a tradeoff then. Things like no right-click will deter some people, although there is always a way around for the more determined.

If the "ambitious" ones are going to find a way around safeguards anyway, is it worth alienating the merely curious to try to block the inevitable? What is a slap to some becomes a dare for others.

dvessel
07-02-2006, 05:26 PM
I'm not even sure on what your trying to accomplish. What are these music files for? Are they for sale and you just want to give a sample of the music?

There are a couple of things you can do. Encode everything 2wice. A very low bitrate or cut off version and serve them as samples and then keep the real files in their own hidden area. Allowing paid downloads is a topic in itself.

If you just want to allow streaming then a streaming server is all you need. It's its' own app that must run on the server with a dedicated IP address. Should talk to support first about it. I've heard conflicting reports on what's allowed.

There are some commercial versions but the darwin streaming server is open source/free. Audio will stream on demand & leave no trace of the file. It can do MP3 among other formats.

http://developer.apple.com/opensource/server/streaming/index.html

hlsJeff
07-02-2006, 05:39 PM
Yes, the music is for sale, with links to places like iTunes to make the purchases. Of course people can listen to the songs at iTunes, etc., but we prefer to provide the music on-site, in our environment, with our features. I will check out the the darwin streaming server. Perhaps limiting the version people hear in some way will end up as the best solution in our case. Thank you for you help.

rando
07-03-2006, 10:45 PM
If you use your .htaccess to set the filetype for mp3s to "application/octet-stream", this should force a download.

Resonant1
07-05-2006, 05:18 PM
When you download an executable file, you may be asked if you wish to run the program "mid air" or if you wish to save it to your hard drive and you will run it yourself later.
Just a note on the Windows take on that dialog. Regardless of whether you select "Open" or "Save", Windows downloads the file before doing anything. If you selected "Open" then it saves the file in a location of its own choosing, and then launches the appropriate application. If you select "Save" then it asks you where you want the file before downloading. Either way, it hits your hard drive.

I always end up having to go clear the files out of the temporary directory when I have used Open. If you don't want people to see the file, skip direct downloading.