I've spent probably about an hour trying to fix this issue. My goal is to let people download a short WMV file. If I simply post a link, it automatically goes into Media Player and not the download screen. So I came up with the following script to have a download window pop up instead:
Code: Select all
//$fpath = Path of the file on the server
//$download_file_name = is the name of file, how it will appear for a user
$len = @filesize($fpath);
header("Content-Type: application/x-video-wmv");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$len);
header("Content-disposition: attachment; filename=\"$download_file_name\"");
if(@readfile($fpath) === false)
ShowError("ERROR: Cannot output the file, please contact administrator...");