shanely's avatar

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.

0 likes
6 replies
AddWebContribution's avatar

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);
shanely's avatar

@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.

AddWebContribution's avatar

@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

shanely's avatar

@saurabhd,

Is this will show in storage/app/public/imgprofile ?

I mean my imgprofile is located at inside public folder storage/app/public/

Please or to participate in this conversation.