PHP scripting problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a VERY frustrating script problem I hope some one can help me with.
I am using part of the following PHP download script to allow users to
download files from my website:

$file = '/download/whiteskullvalley.exe';
header('Content-Description: File Transfer');
header("Content-Type: application/octet-stream");
header('Content-Length: ' . filesize($filename));
header('Content-Disposition: attachment; filename=' . basename($file));

Everything works fine as long as the file size is relatively small (say
around 5 MB) but if I try and use it to download a large file (say around 50
MB) I get Error 500 "Internal Server Error" and when I check my error log I

Premature end of script headers: /web/cgi-bin/php4

I have also tried a few different download scripts and they all give me the
same error.

Any help with this would be greatly appreciated

Re: PHP scripting problem

Quoted text here. Click to load it

I do the following with my code:

$h = fopen($file, "rb");
$content_len = (int) filesize($file);
$content_file = fread($h, $content_len);

@ini_set('zlib.output_compression', 'Off');
header("Pragma: no-cache");
header("Cache-control: private");

header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header('Content-Transfer-Encoding: none');
  header('Content-Type: application/octetstream; name="' . $file . '"');
  header('Content-Type: application/octet-stream; name="' . $file . '"');

header('Content-Disposition: attachment; filename="' . $file . '"');
header("Content-length: $content_len");
echo $content_file;

DeeDee, don't press that button!  DeeDee!  NO!  Dee...

Re: PHP scripting problem

skadmin wrote:

Quoted text here. Click to load it


Site Timeline