Forum Moderators: mack

Message Too Old, No Replies

Dowlnoad Of WAV files

My WAV files are opening. I want them to download instead

         

Web_Student

3:26 am on Jul 10, 2007 (gmt 0)

10+ Year Member



Where can I find the HTML code to invoke a user-download of a Wave file (i.e., "something.wav", a sound file) on my site, instead of the thing automatically playing through the speakers when the user clicks on the link?

What I'm getting at this moment is either...

-- A browser window opens, and it takes minutes as it prepares a meaningless array of binary alphabet soup for the screen

-- The file automatically begins playing through the computer speakers as some sort of sub-function invoked by the browser itself.

What I want is

[1] User clicks on the link, then [2] The file normally downloads

As for the download itself, perhaps it should ask the user where to put it. That's an ancillary detail for later. What I want is the HTML code to invoke a file download when the user clicks the link.

A choice between opening or downloading might be okay. I'm trying to avoid big-time bandwidth from users who want to listen to the same WAV file multiple times.

I checked a couple of free HTML tutorial sites, and couldn't find the code for this. Suggestions, examples, and instruction are both welcome and requested.

lavazza

3:53 am on Jul 10, 2007 (gmt 0)

10+ Year Member



By default, a browser will open any file that is in a format it understands/supports and - (I think) without some rather convoluted browser sniffing - you have no idea what your users UAs support

One 'workaround' is to upload the files to your server in a zipped (or similar) format

I have a hunch that no browsers (by default) will unzip anything

I'm not sure how well this approach would work across platforms though

lavazza

6:00 am on Jul 10, 2007 (gmt 0)

10+ Year Member



Now I've read about it again... I remember! :)

www.webdiner.com Add A Downloadable File to Your Web Site [webdiner.com]

Windows: Zip
Mac: Stuff
Zipping and Stuffing programs are available at Tucows and Shareware.com.

Files that are not zipped or stuffed... ... ...

SteveWh

6:12 am on Jul 10, 2007 (gmt 0)

10+ Year Member



Well, I haven't tried .wav files, but I have an .mp3 file on my site. Simply uploaded the file to the server, created a HTML text link to it. When the user clicks the link, a dialog box opens asking if they want to open it or save it.

To stream it, I created a .m3u file. If the user clicks on that, they get the same Open/Save choice. Save saves the text file (which isn't very useful usually). Open opens the .m3u file which causes the mp3 file to stream.

Maybe you are encountering a "MIME type" problem. <- That's the term to do a web search on. You might have to specially define the MIME type in your server configuration. (In Apache, it's cpanel > MIME Types.)

When a screenful of garbage displays in the browser, it's usually a MIME type problem. In IE security settings, there is an option, "Open files based on content rather than file extension". How that option is set is also relevant to this type of problem.

[edited by: SteveWh at 6:15 am (utc) on July 10, 2007]

thecoalman

6:34 am on Jul 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



To force the browser to open the "save as" instead of the default behavior try adding this to a htaccess file. Just open notepad and paste the following, save as .htaccess and upload to the directory your wav files are in.

<Files *.wav>
ForceType application/octet-stream
Header set Content-Disposition attachment
</Files>

If you want to save bandwidth I'd suggest converting them to mp3 or wma, roughly 1/10th the file size at comparable quality. .wav is uncompressed.