View Full Version : Use .haccess to force download music

03-28-2003, 05:38 PM
I place an .haccess file in my mp3 directory in my web in order to force visitors browsers to download linked mp3 files as I wrote in www.javascriptkit.com.

They say "to force a file to be downloaded, via the save as browser featue, you simply set a MINE type to application/octet-stream and tha immediately prompts you for the download".

The .htaccess file I do understood I do have to place in my mp3 directory is just:
AddType application/actet-stream mp3

I try but it doesn't work. Why?

03-28-2003, 06:07 PM
Originally posted by jfari

AddType application/actet-stream mp3

Spelling, maybe? application/octet-stream

Also beware that iew doen't always obey mime-types and run the file instead of download.

03-28-2003, 06:32 PM
He... You just misunderstood what they said.
It means that when you'll click on link with target set to something like /dir_where_such_htpasswd_resides/your_file.mp3
you'll see "Save as..." dialog box

03-28-2003, 11:43 PM
Sorry, I wrote wrong on this forum, NOT IN THE .htaccess file:

AddType application/octet-stream mp3

This is the only line I wrote on the .htaccess file placed in my mp3 folder.

As I do understood, it may force mp3's files placed in this folder to open the download dialog box on browsers than chick on their links, instead of be played from the web.

03-29-2003, 12:04 AM
I'd do it with PHP - like this thread (http://www.codingforums.com/showthread.php?s=&threadid=16385)

04-03-2003, 12:33 AM
I try with .php file, but I recieve an INTERNAL ERROR from the server.

I upload a download.php file like this:

<title>Gestor de Descargas</title>

$saveName = stripslashes($HTTP_GET_VARS["name"]);

$savePath = stripslashes($HTTP_GET_VARS["path"]);

header ("Content-Type: application/octet-stream");

header ("Content-Disposition: attachment; filename=$saveName");

header ("Content-Transfer-Encoding: binary");



And I point the download.php in my HTML page for download with this link:

<a title="MP3 download" href="/download.php/?path=mp3/cpr_ln.mp3&name=cpr_ln.mp3">MP3</A>

Permision cmod to 744. And I recieve this message:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@rootslatino.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

After two days trying I AM LOST. Any idea to help me?

04-03-2003, 01:03 AM
Which browser are you trying this with? You may want to read this entry in the WDG FAQ:

04-04-2003, 06:15 PM
Thanks. ¡Great link! But I still can not solve my problem.

What about to place a CGi? Should any CGI force download?

04-08-2003, 05:04 PM
Zip it up. :D
Can't say for sure but I've never heard that can be done in a reliable way.