Hi,
Thanks for your reply. This is an example of the code I have been using. It is just one example of many different combinations of headers I have tried, as well as various combinations of different ways of reading the file and sending it through the output buffer. This method of sending it through the output buffer however, is preferable to me because it allows me to update a mysql database just before the fclose function, so that the database is only updated if the file download is completed and not before (in case the downlaod gets cancelled or interrupted for example).
<?php
$filename = "../some/path/to/movie.wmv"; (OR .zip for that matter)
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($filename));
header("Content-disposition: attachment; filename=".basename($filename));
if ($fp=fopen($filename, "rb")) {
while(!feof($fp)) {
echo fgets($fp, 4096);
}
// some php code which updates mysql db
}
//close file
fclose($fp);
?>
As I said, works a treat for .mp3 files, text files, images etc. but .wmv files and .zip files get corrupted.
So far, I have added the following to the httpd.conf file and the mime.types files in the configuration folder for Apache - same problem.
AddType video/x-ms-asf asf asx
AddType audio/x-ms-wma wma
AddType audio/x-ms-wax wax
AddType video/x-ms-wmv wmv
AddType video/x-ms-wvx wvx
I have also altered the DefaultType to application/octet-stream - same problem
The movie files play normally on the server when accessed directly with media player, and if I call the download through Apache simply by calling
<?php
header ("Location: ../some/path/movie.wmv");
?>
then the movie downloades perfectly and is not corrupted - only I don’t want to use ths method because it allow no scope to update my database after the download is completed.
I am sure it is the server settings because if I upload this exact same code to a remote server, it works fine - just corrupts on my localhost, testing server.
I confess to not knowing what zlib.output compression is.
I have come across another problem which I think is directly related. The above php code using fopen and echo fgets etc. works well albeit currupting the movie files. However, I am getting the filename for the download from a $_SESSION variable. If I use session_start before and define
$filename = $_SESSION[filename];
then even worse!! - the server stalls and gives a ‘Cannot find server or DNS error’
Thanks for your interest - really look forward to your reply.
Pertwee.