Image upload from url in php
Posted by Raj
Image upload from url in php
In this Article,I will explain how to upload image from url using php.I have written simple script using php functions to upload image from another domain.
Example: Image upload to URL.
<?php
display_errors(0);
$url = "http://www.example.com/logo.jpg";
$file_name= substr($url, strrpos($url,"/")+1,
strlen($url)-strrpos($url,"/")); //Retrive file name from url
$img = file_get_contents($url);//get contents of file
$f = fopen($file_name, 'w');//Open file
fwrite($f, $img);//Write File
fclose($f);
?>
I hope above script will help you to upload image from URL in php.
Cheers :)
In this Article,I will explain how to upload image from url using php.I have written simple script using php functions to upload image from another domain.
Example: Image upload to URL.
<?php
display_errors(0);
$url = "http://www.example.com/logo.jpg";
$file_name= substr($url, strrpos($url,"/")+1,
strlen($url)-strrpos($url,"/")); //Retrive file name from url
$img = file_get_contents($url);//get contents of file
$f = fopen($file_name, 'w');//Open file
fwrite($f, $img);//Write File
fclose($f);
?>
I hope above script will help you to upload image from URL in php.
Cheers :)
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
how to upload a picture,
image upload from url,
PHP,
php upload,
php file upload,
upload with php
.You can leave a response, or trackback from your own site.