Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I save file from external url Laravel public directory

Tags:

file

php

laravel

I wanted to save a file from External Url which would have any kind of file like say "jpg, png, mp4 etc"

I want to save it in the public directory of Laravel App. How could I do that? Any help will be highly appreciated.

I tried the following thing, but it's saving file in my storage folder:

Storage::put($name, $contents);

Thanks

like image 394
Siddharth Avatar asked Sep 25 '17 09:09

Siddharth


1 Answers

create an img folder in public path and :

 $image = file_get_contents("https://logos-download.com/wp-content/uploads/2016/09/Laravel_logo.png");


file_put_contents(public_path('img/a.png'), $image);
like image 178
sa-fm Avatar answered Sep 19 '22 14:09

sa-fm