Laravel 4 get image from url

image, laravel, laravel-4, upload

Solution

I don't know if this will help you a lot but you might want to look at the Intervention Library. It's originally intended to be used as an image manipulation library but it provides saving image from url:

$image = Image::make('http://someurl.com/image.jpg')->save('/path/saveAsImageName.jpg');

Problem

OK so when I want to upload an image. I usually do something like: ``` $file = Input::file('image'); $destinationPath = 'whereEver'; $filename = $file->getClientOriginalName(); $uploadSuccess = Input::file('image')->move($destinationPath, $filename); if( $uploadSuccess ) { // save the url } ``` This works fine when the user uploads the image. But how do I save an image from an URL??? If I try something like: ``` $url = 'http://www.whereEver.com/some/image'; $file = file_get_contents($url); ``` and then: ``` $filename = $file->getClientOriginalName(); $uploadSuccess = Input::file('image')->move($destinationPath, $filename); ``` I get the following error: ``` Call to a member function move() on a non-object ``` So, how do I upload an image from a URL with laravel 4?? Amy help greatly appreciated.

Original source

Related problems