Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving media files

Status
Not open for further replies.

enderhegemon

Technical User
Jan 29, 2006
7
CA
Hi,

I've created a site where there are three video files available for download (2 .mov, .divx). The problem is that when a link is pressed the file loads in the browser (gibberish for the .divx file). I want the file to be downloaded to the client's computer when the link is pressed (open the save dialog box). I've seen this dicussed on the web, but nothing concrete (usually an ASP solution). Any help would be appreciated. Thanks!
 
Change the MIME type of the file being delivered (server-side) to some generic binary type. Ask in the forum for your web server if you don't know how to do this.

Hope this helps,
Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks Dan.

Apologies for not replying sooner.

Yes, your answer leads me in the right direction. I will look into it further. There seem to be PHP solutions, but I will have to look into them further.

Thanks, again.
 
You didn't say how you were linking the files - if it's a straight <a href="something.mov"> type of thing, then definitely, check to see that all is well on the server, because that should work. However, the browser could also mess it up - make sure that the browser knows that you want to download .mov files rather than display them in the browser (the defaults should be right to either play the video or offer to save the file, but if the settings have been overridden by something that doesn't make sense, that could cause the problem you described).

If, rather than a straight link to the video file, you are linking a server-side script (like PHP or ASP) that is "serving" the contents of the file upon request (I have a situation myself where I am doing that), then you have to make sure you are setting the headers correctly in your code. I don't know ASP, but in PHP it would be the header() function. For example, for the mov file:
Code:
header("Content-Type: video/quicktime");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$size-of-file);
@readfile($file);  //or however you are passing the data through
Hope this helps.
 
Thanks OsakaWebbie,

I am linking directly with <a href...> I will look further into the situation with the advice you (and others have given me). Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top