Timeout while creating zipfile for download

Posted on 2005-05-04
Last Modified: 2006-11-18

A zip file should be automatically created and streamed out for download.
During the creation of the zipfile (using the code
the browser times out.

using either in the script
set_time_limit (0);
ini_set("max_execution_time", 0);

with 0 or a really large number does not fix the problem.

What's the hint?

Question by:SWB-Consulting
    LVL 5

    Expert Comment


    Most web servers have their own time limit that will override PHP's time limit.  In apache it's called "Timeout" in the httpd.conf.  Do you know what that is set to?

    Hope this helps

    Author Comment


    it's set to 300 (I assume that's in seconds?) on the server. Actually the session timeouts after about 30 seconds.

    Apache 1.3 on linux, php 4.3.4 ...

    LVL 5

    Accepted Solution

    If you have control of the server environment, I would change the max_execution_time in the php.ini, restart apache, and see if you still have the problem.  If you don't have the problem anymore, something is going wrong with the set_time_limit call (I don't think you can use ini_set for max_execution_time, can you?).
    LVL 7

    Expert Comment

    Zipping with gzip? or zip? I wonder... Does it say max execution time hit as an error, or does the screen go blank?

    Author Comment

    Hi guys,

    a zip file. The php code that generates the zip file is linked within the initial question. it does everything within php, no shell commands are executed.

    I have increased max_execution_time to 12hrs and it does not help.

    Any other ideas?

    If this problem is not solvable on this way, I change the page to create the zip, store it at a certain path and show a download link to the user (actually I preferre to stream it directly to the user). How would I "entertain" the browser while creating the zip?
    (If I stream the file to the user directly (without sending a download link) I can't send out anything to the browser, because the header is updated with the filesize, after the zip file is created. )


    Author Comment

    Finally I figured out, that the mem limitation caused the problem. The zip file was simply to large to be kept in mem....

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Title # Comments Views Activity
    Don't send email 6 43
    Problem to echo 6 29
    Generating Excel in php 5 30
    Constructing a Query Using Escaped Variables 3 22
    As this topic comes over and over again in different forms, I've finally decided to write a short (yea, right...) article / tutorial about pagination with PHP with MySQL database. There are dozens of these kind of tutorials, I know - I wanted to mak…
    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now