SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Thread: Zip Files

  1. #1
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Zip Files

    I am trying to download a zip file through a link in my email. Sometimes it downloads and sometimes it doesn't.
    I am wondering if server settings has something to do with it?
    any help would be appreciated. Thanks

  2. #2
    SitePoint Guru r2d2's Avatar
    Join Date
    Dec 2003
    Location
    In my van, fool!
    Posts
    646
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this zip file stored on your server? Is it served by a PHP script?

    When you say it doesn't work - what happens?

  3. #3
    SitePoint Member
    Join Date
    Jun 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the zip file already has contained in server may not work.

  4. #4
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,023
    Mentioned
    62 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by phprogrammers View Post
    I am trying to download a zip file through a link in my email. Sometimes it downloads and sometimes it doesn't.
    I am wondering if server settings has something to do with it?
    any help would be appreciated. Thanks
    Since zipfiles are large my first guess is you're hitting the file_upload limit. The default setting is only 2MB. Check your configuration.

  5. #5
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @r2d2
    Yes it is on our server and I have made it through php script
    require_once('class.zip.php');
    $zipfilename = 'zipfiles/productName.zip';
    When I say it doesn't work I mean that if I download the zip file through FTP it downloads fine. And if I download it through the link that I get after buying the product, it downloads sometimes half and some time few bytes and sometimes it download the whole file perfectly.

    @frworkbd
    sorry didn't get you...

    @Michael Morris
    No I am not uploading it. Plus file_upload limit for the server is 20MB and the zip file I am trying to download is 5MB. The file is already on the server, actually I make this zip file through PHP. And it downloads fine through FTP.

  6. #6
    SitePoint Guru r2d2's Avatar
    Join Date
    Dec 2003
    Location
    In my van, fool!
    Posts
    646
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So is the zip file accessed directly on the server, or through the PHP script? I guess if you're also accessing via FTP, then you are accessing it directly. Have you tried using a known 'good' zip file, rather than one created by your PHP script?

  7. #7
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,023
    Mentioned
    62 Post(s)
    Tagged
    0 Thread(s)
    Is the difference between download success and fail the browser used? For example, IE requires you send the file's size as one of the headers for downloading to work.

  8. #8
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @r2d2
    No i haven't tried any other zip other then made by the PHP script, but the problem is it does work sometimes.
    The code i use for downloading is

    if($db->col["digi_console"] == 'Yes'){
    $filename = "./zipfiles/".$db->col["product_id"].".zip";
    }else{
    $filename = "./content/download/".$db->col["digital_product_file"];
    }

    header("Pragma: public");
    header("Expires: 0"); // set expiration time
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");

    header("Content-Type: application/force-download");
    header("Content-Type: application/octet-stream");
    header("Content-Type: application/download");

    header("Content-Disposition: attachment; filename=".basename($filename).";");

    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".filesize($filename));
    if( !ini_get('safe_mode') )
    set_time_limit(360000000);

    readfile("$filename");

    exit();


    @Michael Morris
    I have tried on the firefox and does work sometimes.

  9. #9
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,023
    Mentioned
    62 Post(s)
    Tagged
    0 Thread(s)

  10. #10
    SitePoint Guru r2d2's Avatar
    Join Date
    Dec 2003
    Location
    In my van, fool!
    Posts
    646
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just use this for created downloads via PHP:

    PHP Code:
            header("Content-Disposition: filename=$file");
            
    header("Content-type: application/octet-stream");
            
    readfile($file); 
    Perhaps try removing some of the other header calls you have?

  11. #11
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Michael Morris
    I am not using HTTPS , but see the thing is I checked it on Firefox and chrome and it did downloaded the whole thing sometimes. So i am wondering if this has something to do with the bandwidth or server settings? just confused....

    @r2d2
    Same problem it did worked the first time but then didn't work anymore. I also tried to remove header calls but of no use.

  12. #12
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,023
    Mentioned
    62 Post(s)
    Tagged
    0 Thread(s)
    To rule out bandwidth or server policy issues test the script on your local machine using XAMPP


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •