tmp files in laravel 8 public folder

When I upload files (move actually) to the public folder in laravel 8, they are stored as .tmp files and when I attempt to store files in storage folder, it says failed to open stream: permission denied. Is there some kind of write permission I should enable? or am I missing something in the code?

view screebshot

     if($request->file('file')) {

         $uniqueFileName = uniqid() . $request->file('file')->getClientOriginalName();

         $post = new Post();
         $post->name = request('name');
         $post->email = request('email');
         $post->doc = $uniqueFileName;
         //I also tried to store files here, but says "failed to open stream: permission denied"


         return redirect()->back();


2 answers

  • answered 2021-04-21 13:11 Brian Highforce Thomas

    You need to change the permissions using this command: chmod -R 777 storage

  • answered 2021-04-21 13:11 Wailan Tirajoh

    Try on terminal sudo chmod -R 777 public it will change the directory permission