Downloads fail when content-length header is sent
Posted: Sat Jan 13, 2007 11:39 pm
feyd | Please use
When the content-length header is commented out, some users can download successfully, while others get incomplete zips.
Could anyone suggest, please, what might be going on here? Thanks.
P.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
The following code (run from a shared linux/apache web server) fails at the end of the download with a "source file could not be read" error at the client.Code: Select all
$path = "xxx/";
$file = "yyy.zip";
$filetype = "application/x-zip-compressed";
$fsize = filesize( $path . $file );
header( "Content-Disposition: attachment; filename=\"$file\"");
header( 'Content-type: '. $filetype );
header("Content-Length: $fsize" );
header( 'Pragma: no-cache' );
header( 'Expires: 0' );
return @readfile( $path . $file );Could anyone suggest, please, what might be going on here? Thanks.
P.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]