Jump to content

File download problem


pzbrawl

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.