Quick Search:
Oracle PL/SQL Code Library
Find Or Post Oracle Jobs
Oracle Discussion & Chat
 PHP Code: Saving Remote Images With PHP Jump to:  
Category: >> PHP Code >> Saving Remote Images With PHP Bookmark and Share

<< lastnext >>

Snippet Name: Saving Remote Images With PHP

Description: Two ways to save remote images with PHP. The second way is useful if the allow_url_fopen function is disabled.

Also see:
» Saving Remote Images With PHP
» Include All Files In A Directory
» More File Type Detection in PHP
» Get Current Page URL
» Get Current Directory Name
» Measure script run time
» Random Image from Directory
» Text to GIF
» Write to File example
» Simple image scaling
» Show current time as PNG-image
» Check if an image exists (GD)
» Check if a file exists
» Gradient Image Generator
» Export table to Excel or MS Word file
» Show basic image info
» Write text onto an image
» Storing images in a database
» Make grayscaled image
» Count lines in file
» Copy File From Server
» CAPTCHA w/ GD Image Library
» Truncate URLs for clean appearance.
» Calculate File Size In Directory

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009

// get a remote image and save it 
// $path example: '/home/www/images/myimage.jpg'
$remote_img = 'http://www.somwhere.com/images/image.jpg';
$img = imagecreatefromjpeg($remote_img);
$path = 'images/';
imagejpeg($img, $path);
// Alternative Image Saving Using cURL - useful if 
// the allow_url_fopen function is disabled. 
// $fullpathexample: '/home/www/images/myimage.jpg'
FUNCTION save_image($img, $fullpath){
	$ch = curl_init ($img);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
	curl_close ($ch);
	$fp = FOPEN($fullpath,'x');
	FWRITE($fp, $rawdata);

Oracle Magazine
and Oracle White Papers

SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 40 users online    © 2009 psoug.org

Forgot your password?