Getting images from one site to my server

Discussion in 'PHP' started by matthewk, Sep 21, 2006.

  1. #1
    Hey, i have a list of urls to images an another server(s). the list is stored in a database, and i was wondering if there is any way to save those images to my server just with the url of the image. dont worry, im not taking copy written images or anything like that. the site gives full permission for anyone to take their images or hotlink. i just would rather size them, as hotlinking will in the long run make my site and their site slower. i know i can just right click on the image and got to save-as...etc..., but that could take a long long long time with the number of images i need.
     
    matthewk, Sep 21, 2006 IP
  2. Big 'G'

    Big 'G' Member

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    48
    #2
    Top of my head use curl to get the image and save the result while looping through the db
     
    Big 'G', Sep 21, 2006 IP
  3. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #3
    You could use copy function in PHP.
     
    SoKickIt, Sep 21, 2006 IP
  4. matthewk

    matthewk Guest

    Messages:
    265
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    would something like this work?
    
    <?php
    $file = 'otherserverpath\filename';
    $newfile = 'myserverpath\filename';
    
    if (!copy($file, $newfile)) {
       echo "failed to copy $file...\n";
    }
    ?>
    
    PHP:
     
    matthewk, Sep 21, 2006 IP
  5. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #5

    Yes.

    otherserverpath - http://www.something...
    myserverpath - folder on your server. Example: /folder1/folder2/folder3/
     
    SoKickIt, Sep 21, 2006 IP
  6. matthewk

    matthewk Guest

    Messages:
    265
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    good stuff, thanks for the help. ill give it a try when i get home and let you guys know if it works. Thanks again.

    Matthew
     
    matthewk, Sep 21, 2006 IP