I am trying to:
- check whether an image file exists on a server,
- check whether it does not exist on another server, and if not exists
- to copy from the first location to the second.
I am using cURL. First step to capture the image from the first
server. When I return this image to the browser I get a lot of strange
characters. So has this captured the image and what do I use next to
upload to the second server?
I was trying to use file_exists and had problems referencing the file
location as "http://wwww.mysite.com/pic.jpg". But I know I can also
look at using readfile() and file_put_contents(), $fp = fopen(),
fputs(), fpassthru() etc. What is best way?
// create a new cURL resource
$ch = curl_init();
$url="http://wwww.mysite.com/pic.jpg";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
// copy the handle
$ch2 = curl_copy_handle($ch);
// grab URL and pass it to the browser
curl_exec($ch2);
// close cURL resources, and free up system resources
curl_close($ch2);
curl_close($ch);
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php