Hi,

I've just started learning about php... I've been doing research regards to this for a long time... I would like to download pics from a http path to my desktop...how do i go about that without in need of any forms or interactivity...

Thank you...

    i've already manage to get the contents...but i wanna placed the content to a folder in my desktop...

    Below is what i've have :-

    foreach($photos['data'] as $photo)
    {
    //Display Pic
    echo "<img src='{$photo['source']}' />", "<br /><br />";
    $file = $photo['source'];
    //Display Path
    echo $file ;
    //Output : http://sphotos.ak.fbcdn.net/hphotos-ak-snc4/hs1354.snc4 /162605_111165078956516_100001890733297_87876_1449653_n.jpg

    }

    Now what i missing is the code to upload/download to my folder @ my desktop...

      Hi...

      Im able to get the contents but now i wanna store the image to a folder. Im using a public server.

      foreach($photos['data'] as $photo)
      {
      //display image
      echo "<img src='{$photo['source']}' />", "<br /><br />";

      	$file = $photo['source'];
      
      	//display image path
      	//output: [url]http://sphotos.ak.fbcdn.net/hphotos-ak-snc4/hs1354.snc4/162605_111165078956516_100001890733297_87876_1449653_n.jpg[/url]
      	echo $file ;

      }

        n8nie;10972797 wrote:

        Hi...

        Im able to get the contents but now i wanna store the image to a folder. Im using a public server.

        does this mean php is not running on the machine you want the images to end up on?

          I get what you mean sorry for the confusion...I'm running php on my public server and would like to store the image in a sub folder on my public server...

            
              // URL of the file you want to get from the internet
              $remote_file = "http://my.server/path/to/my/image.jpg";
            
              // Path to the file you want to create on your machine
              $local_file = "C:/Documents & Settings/MyUser/Desktop/A Folder/image.jpg";
            
              // Get the file and save it to the local machine
              file_put_contents($local_file,file_get_contents($remote_file));
            
            

              Hi Dave...

              I get this error...Is it due to my $remote_file??

              Error:-

                n8nie wrote:

                Is it due to my $remote_file??

                Hard to tell from the abbreviated message you showed us.. what's the full error message?

                  Full error message :-

                  Warning: file_put_contents(/home/davidyeo/public_html/2B10030/php/) [function.file-put-contents]: failed to open stream: Is a directory in /home/davidyeo/public_html/2B10030/php/index.php on line 29

                    The contents of your $local_file is a directory, not a file. You need to specify the full path to a file, preferably one that doesn't yet exist. You can't just tell the script which directory to put the file in, but if you want to keep the same file name as the remote server you can do

                      // URL of the file you want to get from the internet 
                      $remote_file = "http://my.server/path/to/my/image.jpg"; 
                    
                      // Path to the file you want to create on your machine 
                      $local_file = "C:/Documents & Settings/MyUser/Desktop/A Folder/".basename($remote_file); 
                    
                      Write a Reply...