FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Image Copying





imagefree
I want to copy an image from the net to a dir. See the example.


i want to copy an image http://www.example.com/image.jpg to my website in the same directlry where the script is located. Please help me doing this.

I will do all the file movements, just help me copying image. (using php)

Thanks
(Example of this question is HTTP image uploading that most image hosts allow)
rvec
http://nl.php.net/manual/en/function.curl-init.php
Quote:
Code:
<?php
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);
?>

that is the standard curl script. Use it like this to save an image in $image


Code:
<?php
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/image.jpg");
curl_setopt($ch, CURLOPT_HEADER, 0);

//make it not echo the content but return it
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// execute the curl comand and save the image
$image = curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);

//make the script look like an image
header('Content-Type: image/jpeg');

//echo the image (you could also manipulate the image here)
echo $image;
?>
Related topics
File upload with PHP, Build an upload database for your site
Image resizer
Random image for your gallery
Image transparency script
751 Useful Windows XP Files
Replace the art and personal pictures with an image gallery?
Can some install Image Magick?
Image Processing in C++ by Shirish
Tutorial: Image Rollovers w/ Javascript
PHP Image Upload (MySQL/Folder)
online / offline image dilemma
How To Make A Mini-Image for safedisc 4
phbb skin
Uploading and resizing an image
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.