Mathias Hillmann
Mathias Hillmann

Reputation: 1827

Laravel Storage::putFileAs not saving the file even though it returns the path to that file as if saved

I have the following code:

public function store(string $folder, $file){
       $ret = Storage::putFileAs("/application/public/storage/1/{$folder}", $file, $file->getClientOriginalName());
       return $ret;
   }
}

Where the path to the putFileAs function ends up being /application/public/storage/1/tasks/NXL-1 after feeding the variable $folder, but even tho the variable $ret in the return has the path to that file as if it worked /application/public/storage/1/tasks/NXL-1/image.png, when I go to that folder the file is not there. What should I do?

Upvotes: 1

Views: 1634

Answers (1)

Diptanu Chakraborty
Diptanu Chakraborty

Reputation: 48

you can use storeAs method in laravel 8.

for example

$imageFileName =  $request->image_name->getClientOriginalname();
$request->image_name->storeAs('images/portfolio', $imageFileName, 'publicfolder');

Upvotes: 2

Related Questions