SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict brain's Avatar
    Join Date
    Sep 2001
    Location
    Amsterdam
    Posts
    249
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    upload extern hosted image

    Is it possible with php to upload an extern hosted image to my own site?

    Maybe with a form that I can input:

    http://www.otherdomain.com/images/DCS_1003.jpg

    And that this image will be copied to my own site after which I can do whatever I want to do with it.

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Yes, you can download images from other servers. If the allow_url_fopen directive is enabled in PHP's configuration, you can use file_get_contents to download the file (if it isn't enabled, you'll have to use sockets to download the file - if this is the case, let me know if you need help). An example of how it's done:

    PHP Code:
    $image_uri 'http://www.otherdomain.com/images/DCS_1003.jpg';

    $image_file fopen('new-filename.jpg''w');
    fwrite($image_filefile_get_contents($image_uri));

    fclose($image_file); 
    ERIK RIKLUND :: Yes, I've been gone quite a while.


Bookmarks

Posting Permissions

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