1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Default How To download multiple files simultaneously with php

Discussion in 'PHP & Perl' started by nalza, Mar 6, 2009.

  1. nalza

    nalza Newbie

    Joined:
    Feb 11, 2008
    Messages:
    7
    Likes Received:
    2
    Hi

    i need a simple php code but i can't seem to figure it out since i am not a php expert

    i have a list of image url in a text file (say image.txt).

    i want to run a php script to get all the image from that url file and save it to images folder on my server.

    have been searching for hours but just could not make this to work.

    any help would be much appreciated.

    thank you.
     
  2. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    PHP:
    <?php
    $file1 
    "./image.txt";
    $lines file($file1);
    foreach(
    $lines as $line_num => $line)
    {
    $png imagecreatefrompng("$line");
    imagegif($png"./$i.gif");
    imagedestroy($png);
    $i++;
    }
    ?>
    This will work corectly only for PNG files. It will save all files from your list as:
    1.gif
    2.gif
    3.gif

    etc.
     
  3. lord

    lord Junior Member

    Joined:
    Jan 21, 2009
    Messages:
    176
    Likes Received:
    251
    you can also use

    HTML:
    imagecreatefromjpeg
    imagecreatefromgif