1

If I uploaded the file works all perfectly, but when I avoid to upload it ( is optional ) I get this error:

fread(): read of 8192 bytes failed with errno=21 Is a directory

In my controller I tried to check if file exists with the function hasFile but it seems doesn't work:

 if($request->hasFile('my_file')) {
          $fileName = time().'.'.$request->my_file->extension();
          $request->my_file->move(public_path('uploads'), $fileName);
          $content->my_file= $fileName;
        }

Also I tried to print the content of $request->my_file to debug with dd($request->my_file). It's null.

The stranger thing is that also if $request->my_file is null this check getting the error:

if($request->file('my_file') != null)
Roberto Remondini
  • 242
  • 1
  • 6
  • 19

1 Answers1

1

I found and solved the problem. HasFile works correctly but the error was in a next step of saving.

Roberto Remondini
  • 242
  • 1
  • 6
  • 19