68 users online (0 members and 68 guests)  


  Results 1 to 4 of 4

Related

  1. Need help with MySQL fetch    Forum: Databases
    Replies: 2
  2. mysql fetch array error please help    Forum: PHP Forum
    Replies: 10
  3. fetch array problems    Forum: PHP Forum
    Replies: 4
  4. php - fetch array error    Forum: PHP Forum
    Replies: 4
  1. #1
    blink's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2005
    Posts
    19

    How to fetch an image from the internet?

    Hello,

    If I have a static URL for an image on some server, how do I download the image into my HDD with Perl?

  2. #2
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382
    try this:
    Code:
    use File::Copy;
    $old = "http://somewebpage.ext/somefile.jpg";
    $new = "./somefile.jpg";
    copy($old, $new);

  3. #3
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382
    sorry, that code can only work within the server, this code will work out side the server:
    Code:
    use LWP::Simple;
    use File::Copy;
    $old = get('http://website.com/image.jpg') || die "Couldn't find file!";
    $new = "image.jpg";
    open(ADD, ">$new") || die("Couldn't open destination file!");
    print ADD $old;
    close(ADD);

  4. #4
    blink's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2005
    Posts
    19
    Thanks!



Tags for this Thread