Reputation: 7128
I can upload my images while i'm working on local but when I moved my site to host it doesn't upload images while get names of them in database,
my filesystems.php
'default' => env('FILESYSTEM_DRIVER', 'local'),
disks' => [
'local' => [
'driver' => 'local',
'root' => public_path('images/'),
],
....
sample of my upload codes:
if ($request->hasFile('imageOne')) {
$imageOne = $request->file('imageOne');
$filename = 'productone' . '-' . time() . '.' . $imageOne->getClientOriginalExtension();
$location = public_path('images/');
$request->file('imageOne')->move($location, $filename);
$product->imageOne = $filename;
}
Issue:
In host i get uploaded
image name in database
, but no image in mypublic/images
folder.
any idea?
I found interesting folder in my host, as I moved all my public
folder files to server public_html
now it created another folder in my root called public
and inside that has images
folder including all images i uploaded so far!
Questions:
public/images
folder in my root instead of
using my public_html
?Upvotes: 2
Views: 10959
Reputation: 558
I change the public path inside my save image controller to look like this:
if (request()->imagefile->move(public_path('../../public_html/destination'), $imageName))
echo "Yap";
else echo "Nop";
Upvotes: -2
Reputation: 7128
I added this code to my public_html/index.php
file and it's working now.
// set the public path to this directory
$app->bind('path.public', function() {
return __DIR__;
});
Hope it helps.
Upvotes: 6