Reputation: 982
I am using Laravel illuminate/html
and I am trying to upload an image file and store it in /public
in the laravel installation folder. I have got the image from the request:
$img = Request::file('img');
How can I store it in the public folder?
Thanks
Upvotes: 0
Views: 463
Reputation: 17545
You could do this in your controller:
Request::file('img')->move(base_path('public/uploads'));
Or if you wish to specify a generic filename or change filename
$newfilename = str_random(32) .time();
$ newfilename = $newfilename. ".". Request::file('img')->guessClientExtension();
Request::file('img')->move(base_path('public/uploads'), $newfilename);`
Upvotes: 1