Tithira's avatar

Images are not uploaded into Storage even it is linked

I can upload files and make directories from the first model i created. I have linked the sorage and the public folder.The uploading is working fine and i noticed my second controller creates the folder and then doesn't upload the image,instead making a linked folder which i cannot even open.

My not working storage path : $folder = storage_path('app/public/posts/' . Auth::id() . '/' ); if i change the directory to any other folder otherthan the public folder like app/dealers it works and uploads the images.I am guessing what could be the cause.I am using Image intervention library.


       $image = $request->file('customFile');
        
        $folder = storage_path('app/public/dealers/' . Auth::id() . '/' );
        //$folder = storage_path('app/dealers/' . Auth::id() . '/' );       This works
        $filename = 'logo'  . '.' . $image->getClientOriginalExtension();

        File::makeDirectory($folder, 0775, true, true);
    $location = storage_path('app/public/dealers/' . Auth::id() . '/' . $filename);
    Image::make($image)->save($location);

     $dealer->logo = $filename;
     $dealer->save();
        
    $dealer->save();

0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

I would start with dd() to check the paths are all correct

$location = storage_path('app/public/dealers/' . Auth::id() . '/' . $filename);

dd($folder, $filename);
1 like
Tithira's avatar

@SNAPEY - Thanks for the reply @snapey . it gives me the correct path.The folder icon is shown with the symbolic link icon,i cannot open the folder with my text editor when stored in app/public/dealers though when i go through the file explorer , the file has got uploaded and it has worked.Weird !

Please or to participate in this conversation.