nidaakram's avatar

Laravel 5.4: Failed to open stream: Permission denied

I am trying to move a file which will be uploaded to public/foldername but i get this error of failed to open stream: Permission denied. Kindly tell me how to solve this error

Code of file uploading

if(!empty($rep))
    {
        foreach($rep as $rep)
        {
            $filename = $rep->getClientOriginalName();
            $fileSize = $rep->getClientSize();
            $rep->storeAs('public/reportAttachment',$filename);
            $reportId = Report::where('reportId',$request->reportId)->first();
            $reportA = new ReportAttachment;
            $reportA->reportAttachmentFile = $filename;
            $reportA->report_id = $reportId->id;
            $reportA->save();
        }
    }
0 likes
1 reply
rin4ik's avatar
rin4ik
Best Answer
Level 50

try this

$rep->storeAs('/public/reportAttachment',$filename);

Please or to participate in this conversation.