pzbrawl Posted January 18, 2007 Share Posted January 18, 2007 This 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=php:0] $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 );[/code]When the content-length header is not sent, some users can download successfully while others get incomplete zips.Setting type to "application/octet-stream" or "encoding/x-compress" yields the same result.Setting type to "application/gzip" gets rid of the read error when length is set but still yields an invalid zip.Could anyone please suggest what might be going on? Link to comment https://forums.phpfreaks.com/topic/34768-file-download-problem/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.