Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005
    Barcelona (Spain)

    PHP script - downloading huge files

    1. Is this the correct way (efficiency) to do this? (on WinXP box, local server, PHP command line) (no, I can't use the win32 ports of wget, curl, etc)

    2. 8192 (8Kb) is OK? what about a larger 1MB buffer?

    3. Download speed is not a problem, but these scripts should work 24x7 for 2 or 3 days. Is this bad for the 1TB WD hard disk? fwrite=automatic buffering (by WinXP)?

    $handler = get_handler($url1);
    if (!$g = fopen($local_file, 'a'))
    while ($buffer = fread($handler, 8192))
        fwrite($g, $buffer);

  2. #2
    Join Date
    Apr 2009
    Its okay. But if you are using java you can implement threading to handle this in a better way.

  3. #3
    Join Date
    Jul 2008
    Need to see the code of get_handler()
    Looks like it's loading the entire file into ram.

    If it's not, a 8k buffer sounds about right.

    You will also need to modify the loop as follows:
    while (!feof($handler))
        $buffer = fread($handler, 8192);
        fwrite($g, $buffer);

Similar Threads

  1. Files not downloading to users
    By mo_uk in forum Hosting Security and Technology
    Replies: 4
    Last Post: 02-08-2008, 04:30 PM
  2. Replies: 5
    Last Post: 03-03-2007, 02:03 PM
  3. Downloading my PHP files
    By xxkylexx in forum Hosting Security and Technology
    Replies: 3
    Last Post: 05-23-2006, 06:58 PM
  4. downloading .mov files
    By Flumps in forum Web Hosting Lounge
    Replies: 5
    Last Post: 04-07-2006, 05:05 PM
  5. Downloading Files
    By coops in forum Programming Discussion
    Replies: 6
    Last Post: 12-13-2005, 08:46 PM

Posting Permissions

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