mercredi 4 avril 2018

Laravel Intervention Image: Save image directly from dropbox url

I was trying to store image from dropbox url to my local folder with laravel Intervention , but with it i am getting errors after error.

Can anyone please tell me how can i do so ?

My code is this

 $path = 'https://www.dropbox.com/s/vwswp91fiz0m1wd/1200px-Good_Food_Display_-_NCI_Visuals_Online.jpg?dl=0';
        $filename = explode('?',basename($path))[0];
        Image::make($path)->save('images/'.$filename); 

The error i am getting for this is

Unable to init from given binary data.

So i tried the solution from of of stackoverflow post

$path = 'https://www.dropbox.com/s/vwswp91fiz0m1wd/1200px-Good_Food_Display_-_NCI_Visuals_Online.jpg?dl=0';

        $filename = explode('?',basename($path))[0];
        $path = base64_decode($path);
        Image::make($path)->save('images/'.$filename);

But that gave me another error. I tried looking on goggle but i didn't find any solid answer that works for my case Can anyone please help me on this how to download image from dropbox url and save to loacal storage ? Or do i have to add dropbox api or something??



via Chebli Mohamed

1 commentaire: