Results 1 to 4 of 4

Thread: call php function in image url download

  1. #1
    Join Date
    Aug 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default call php function in image url download

    Hey well i need help i want to create a simple image downloading script
    where you insert the image URL and it will download it and place it on
    the server, Any one have any ideas on how i can do this?


    eg...




    http://www.weberdev.com/UserPictures/NoImage.jpg


    thanks

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    If your PHP setup is configured to allow remote files, this should work for you:

    <?php
    $i = file_get_contents('http://...../image.jpg');
    $f = fopen('path/my.jpg','w+');
    fwrite($f,$i);
    fclose($f);
    ?>
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Aug 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How call php function insert image url

    I need to create a simple image downloading script where you insert the image URL and it will download or add it and place it on the server or in the database, Any one have any bright ideas on how i can do this?

    eg:

    The image of 39dollarglasses.com (http://www.39dollarglasses.com/store...164_Brown.jpg), in which i will insert it to my website using php script.. i really appreciate your help.. thanks in advance..

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    $i = file_get_contents($_GET['url']);

    Then just make a form with a field "url" and that will be the url used in the script, or you could link to it like "thatpage.php?url=http://whatever".

    You may want to use error checking, with
    if (file_exists($_GET['url'])) first
    etc.

    As for adding to a database, etc., look here:
    http://php-mysql-tutorial.com
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •