problem in upload image using storage
I need some help please I want to store my uploaded file in storage/app/public/myuploaded
I also set php artisan storage:link
when I upload it.
$attachement = new Attachement();
$imagefile = $request->imagefile;
$filename = Storage::disk('local')->put('myuploaded',$imagefile );
$attachement->filename = $filename;
$attachement->save();
when I look at in the myuploaded folder it save., but in storage link it did not save.
can you help me please.
Thank you in advance.
Set below code into your config/filesystems.php file:
'disks' => [
'local' => [
'driver' => 'local',
'root' => public_path() . '/myuploaded',
],
]
And put function like:
Storage::disk('uploads')->put($filename, $imagefile);
@saurabhd ,
what if I have also another folder like imgprofile ? do I need to add another root ? .. also is this correct disk('uploads') not 'local' ? ..
Thank you in advance.
@shanely: You can set disks label as per your requirement and as well you can setup the with another root like:
'disks' => [
'local' => [
'driver' => 'local',
'root' => public_path() . '/myuploaded',
],
'uploads' => [
'driver' => 'local',
'root' => public_path() . '/imgprofile',
],
]
Read more about Laravel File Storage
@saurabhd,
Is this will show in storage/app/public/imgprofile ?
I mean my imgprofile is located at inside public folder
storage/app/public/
@shanely: Not getting your point, can you please elaborate it in few more word?
Please or to participate in this conversation.