#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Hong Kong
    Posts
    73
    Rep Power
    15
    Hello,

    I'd like to save a remote server file in the local server harddisk. How can i do it in PHP?

    eg. a user provided a url:
    http://example.com/myphoto.jpg

    the program can grab the myphoto.jpg and write it to local disk.
    is there anyone could give me some suggestion?
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Ribeirao Preto, SP, Brasil
    Posts
    5
    Rep Power
    0
    Well, you need run Apache Server (or your prefered server) on local machine and write this PHP Script:

    <?php
    $file_url = "http://www.site.com.br/file.zip";

    $fp = fopen($file_url,"r");
    $fp2 = fopen("file.zip", "w");
    while (!feof($fp)) {
    $buf = fread($fp, 1024);
    fput($fp2, $buf);
    }
    fclose($fp);
    fclose($fp2);
    ?>

    and run this script.....that's it!

    (tks IdNotFound for cod)

    []'s


    ------------------
    Jonis Maurin
    I'm programming from brazil!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Niteroi, RJ, Brazil
    Posts
    30
    Rep Power
    15


    I didn't really tested this code...

    Dunno if it's fput or fputs... etc...

    The rest should work fine...

    ------------------
    Eduardo Teixeira Cardoso
    PHP Programmer from Brazil
    idnotfound@vircio.com.br

Similar Threads

  1. transfer a database from my local databse to a remote machine
    By mshukla in forum MS SQL Development
    Replies: 1
    Last Post: February 17th, 2004, 09:31 AM
  2. Replies: 2
    Last Post: February 12th, 2004, 01:00 PM
  3. Has anyone used Perl to encrypt/decrypt local files?
    By onlywayisup2000 in forum Perl Programming
    Replies: 3
    Last Post: January 12th, 2004, 06:03 PM
  4. Replies: 11
    Last Post: January 3rd, 2004, 12:28 PM
  5. Qmail done remote email@aol.com
    By service123 in forum Mail Server Help
    Replies: 1
    Last Post: December 16th, 2003, 08:58 AM

IMN logo majestic logo threadwatch logo seochat tools logo