9 months ago

Download file from database (storage)

Posted 9 months ago by ziben69

Hello guys,

I did multiple file upload: model File:

class File extends Model
    protected $fillable = [

FileController (store function):

  public function storeFiles(Request $request)

        $this->validate($request, [
            'filename' => 'required',
            'filename.*' => 'mimes:doc,pdf,docx,zip'

            foreach($request->file('filename') as $file)
                $file->move(storage_path('/app/public/files/', $name));
                $data[] = $name;  

        $file = new File();
        $file->title = $request->input('title');
        $file->description = $request->input('description');

        return redirect()->action('[email protected]');

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 sign in or create an account to participate in this conversation.