I pretty much just copied and pasted this from PHP.net's readfile page.
When I run this script, the download dialog pops up but it only downloads about 1kb of the movie. In IE downloads it as "Last Night", no extension, and Firefox downloads it simply as "Last" with no extension. Chrome gets the filename and extension fine.PHP Code:<?php
$file = "C:/wamp/www/Last Night.avi";
$info = pathinfo($file);
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: video/avi');
header('Content-Disposition: attachment; filename='.basename($file, $info["extension"]));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file) or die("File not found");
}
?>
Don't know if it has anything to do with it but when I turn off "display errors" Chrome gives me "This webpage is not available".
Any help would be greatly appreciated. Thanks!


Reply With Quote

Bookmarks