-1

I'm setting up an image upload option to a folder. What caused and how do I fix this error?

PHP in MessageController

public function store(Request $request)
{
    $request->image->store('comments');
}

HTML

<form action="/api/messages" enctype="multipart/form-data" method="post">
    Select image to upload: 
    <input id="fileToUpload" name="fileToUpload" type="file"> 
    <input name="submit" type="submit" value="Upload Image">
</form>

I'm expecting output 200, but getting server error 500.

Qirel
  • 25,449
  • 7
  • 45
  • 62

1 Answers1

1

I believe you are not referencing the image file correctly in the request. Instead, please try doing this:

$request->file('fileToUpload')->store('comments');
George Hanson
  • 2,940
  • 1
  • 6
  • 18