我正在将图像上传选项设置到文件夹。是什么原因引起的,我该如何解决?
MessageController中的PHP
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>
我期望输出200,但出现服务器错误500。
答案 0 :(得分:1)
我相信您在请求中没有正确引用图像文件。相反,请尝试这样做:
$request->file('fileToUpload')->store('comments');