Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

php - 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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

you can use storeAs method in laravel 8.

for example

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...