Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9146807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:50:04+00:00 2026-06-17T10:50:04+00:00

I currently have a script written that begins downloading an large (1.3GB) XML file

  • 0

I currently have a script written that begins downloading an large (1.3GB) XML file from the web but I have encountered a number of problems. This is my code:

   function readfile_chunked ($filename) { 
      $chunksize = 1*(1024*1024); 
      $buffer = ''; 
      $handle = fopen($filename, 'rb'); 
      if ($handle === false) { 
        return false; 
      } 
      while (!feof($handle)) { 
        $buffer = fread($handle, $chunksize); 
        //print $buffer; 

        $myFile = "test.xml";
        $fh = fopen($myFile, 'a') or die("can't open file");
        fwrite($fh, $buffer);
        fclose($fh);
      } 
      return fclose($handle); 
    } 

The first (and main) problem is the following error while downloading saying:

Fatal error: Maximum execution time of 30 seconds exceeded in /Applications/MAMP/htdocs/test/test.php on line 53

As I understand it this is basically a timeout and i’ve read about changing timeout settings in php.ini but i’m conscious that when this application goes live i won’t be able to edit the php.ini file on the shared server.

This problem brings me onto my next one – i want to implement some kind of error-checking and prevention. For example, if the connection to the server goes down i’d like to be able to resume when the connection is restored. I realise this may not be possible though. An alternative would be to compare filesizes of local and remote maybe?

I also need to add an Accept-Encoding: gzip HTTP header in my request.

And that would finally bring me onto some kind of progress notification that I would like, presumably constantly polling with JavaScript comparing local and remote filesizes perhaps?

The first two points, however, would be the most important as currently I can’t download the file I require. Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:50:05+00:00Added an answer on June 17, 2026 at 10:50 am

    Regarding your question about the timeout. I would suggest to run that task as a cron job. When running PHP from the command line, the default setting of maximum execution time is 0 (no time limit). This way you will avoid the guess work on how long it will take to download the file, which is variable that depends on various factors. I believe the majority of shared hosts allow you to run cron jobs.

    For download resuming and gzip, I would suggest using the PEAR package HTTP_Download

    It supports HTTP compression, caching and partial downloads, resuming and sending raw data

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a script that scrapes proxies off websites, but I'm just wondering
I currently have a Perl CGI script that parses incoming XML requests using XML::Simple
I have written a Python script that currently is designed to handle traditional CGI
I have written a little script that reads every hour from a website and
I have a python script that parses an XML file that contains part information
I currently have a script that deletes old log files and then takes any
Currently we have a script that does maven build + tomcat deploy. Deploying to
I currently have a ajax script that dynamically builds two select boxes enabled with
I currently have a python script that runs every few minutes and picks up
I currently have code like this in a web based file called 'view_file.php' to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.