The file name needs to be apart of the call to download
return Storage::download(storage_path('app/public/files/') . $dl->filename);
Hello guys,
I did multiple file upload: model File:
class File extends Model
{
protected $fillable = [
'title',
'description',
'filename'
];
}
FileController (store function):
public function storeFiles(Request $request)
{
$this->validate($request, [
'filename' => 'required',
'filename.*' => 'mimes:doc,pdf,docx,zip'
]);
if($request->hasfile('filename'))
{
foreach($request->file('filename') as $file)
{
$name=$file->getClientOriginalName();
$file->move(storage_path('/app/public/files/', $name));
$data[] = $name;
}
}
$file = new File();
$file->title = $request->input('title');
$file->description = $request->input('description');
$file->filename=json_encode($data);
$file->save();
return redirect()->action('FilesController@flist');
}
and how can I download file now. I have something like this:
public function show($id)
{
$dl = File::find($id);
return Storage::download(storage_path('app/public/files/'), $dl->filename);
}
but it gives to me error:
File not found at path: C:/xampp/htdocs/tbg/storage/app/public/files
and URL: http://localhost/filess/download/8
Can someone help me? Thanks
Please or to participate in this conversation.