How To Uploade File In Storage Folder In Laravel

[Solved] How To Uploade File In Storage Folder In Laravel | Php - Code Explorer | yomemimo.com
Question : how to uploade file in storage folder in laravel

Answered by : muhammad-ishaq

//first run this command to generate symbolic link
php artisan storage:link
//then in controller function
$fileTemp = $request->file('file');
if($fileTemp->isValid()){ $fileExtension = $fileTemp->getClientOriginalExtension(); $fileName = Str::random(4). '.'. $fileExtension; $path = $fileTemp->storeAs(	'public/documents', $fileName );
}
//above code will save your file in 'storage/app/public/documents' location
//and using symbolic link we can access this file here 'public/storage/documents'
//Now Open or download file in blade template
<a href="{{url(Storage::url($document['file']))}}">Open/Download</a>

Source : https://laravel.com/docs/9.x/filesystem#file-uploads | Last Update : Tue, 27 Sep 22

Answers related to how to uploade file in storage folder in laravel

Code Explorer Popular Question For Php