Hi there,
Well, it can be done, and even over HTTP. What you need is a Server Side script that streams the wav file to the browser. The user is presented with a Save As dialog, so they can determine where the file should be saved. It's not possible to circumvent this prompt on the Internet: the browser will not allow it. In an Intranet environment, with relaxed security settings, you may have more luck.
Anyway, the next code block below is for ASP. You'll find a PHP alternative near the end.
Code:
Dim sFullFileName
sFullFileName = "C:\Test.wav"
Response.Contenttype="application/x-unknown"
Response.Addheader "Content-Disposition", "attachment; filename=" & chr(34) & sFileName & chr(34)
Response.Binarywrite GetBinaryFile(sFullFileName)
Function GetBinaryFile(ByVal sFileSpec)
Const adTypeBinary = 1
Dim objStream
Set objStream = Server.Createobject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile sFileSpec
GetBinaryFile = objStream.read
Set objStream = Nothing
End Function
If you put this code in it's own file and create a link to it, you'll be prompted to save the file.
The good thing about this solution is that you are not directly linking to a WAV file within the current web scope. This allows you to add some extra security checks (if necessary of course) before you actually stream the file to the browser.
If you want, you can make the page more dynamic. Instead of using a
hard-coded filename of "C:\Test.wav", you could retrieve the name from the QueryString, a Form variable or whatever suits your needs.
PHP
Code:
<?php
header("Content-type: application/x-unknown");
header("Content-Disposition: attachment;
filename=proposedFileName.wav");
readfile('test.wav');
?>
Hope this helps,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.