Welcome Guest, Not a member yet? Register   Sign In
How to copy images from an external URL to my localhost
#1

[eluser]mi6crazyheart[/eluser]
Hey Guys,
I've stucked in a small problem. Don't know how to solve it...

Problem:
--------
I've an image url: http://img149.imageshack.us/img149/4185/stickynotes.png

I want to copy this image & store in my codeigniter assets folder. I don't know how to do it. Tried a lot of things but didn't get any perfect solution.

Actually my mission is, create an thumbnail of this image & store in my CI application. But, as CI image resize library don't work on url as source of image.. i planned to copy the image to an TEMPORARY folder first & then use the CI's resize library over it...


Please, if any body have any idea how to solve this problem share with me.

Regards
Suresh
#2

[eluser]n0xie[/eluser]
Use curl?

Using Phil's Curl library as an example:
Code:
$this->load->library('curl');
$this->load->helper('file');

$img = $this->curl->simple_get("http://img149.imageshack.us/img149/4185/stickynotes.png");

if ( ! write_file("./public/stickynotes.png", $img))
{
  echo 'unable to write the file';
}
#3

[eluser]mi6crazyheart[/eluser]
@n0xie
Oh thx a lot. It's really a great help for me. Phil’s Curl library is really working kool.....




Theme © iAndrew 2016 - Forum software by © MyBB