vel*_*lvt 3 upload null image laravel
您好,我在使用laravel上传图像时收到以下错误:“调用成员函数getClientOriginalExtension()为null”。
这是我的控制器:
$imageName = rand(11111, 99999) . '.' . $request->file('image')->getClientOriginalExtension();
$destinationPath = 'events';
$fileName = rand(11111, 99999) . '.' . $extension;
$upload_success = $image->move($destinationPath, $imageName);
Run Code Online (Sandbox Code Playgroud)
这是我的看法:
{!! Form::file('image', null, ['class' => 'form-control']) !!}
Run Code Online (Sandbox Code Playgroud)
如何将$ imageName保存到数据库中的pic字段。我试过了,但是没有用。该表在表中保持空白。
$task=$request->user()->tasks()->create([
'name' => $request->name,
'description' => $request->description,
'location' => $request->location,
'pic' => $imageName,
]);
Run Code Online (Sandbox Code Playgroud)
在你form:open你需要'files' => true像下面
Form::open('your_path', array('files'=> true))
Run Code Online (Sandbox Code Playgroud)
要么
<form action="yout path" method="post" enctype="multipart/form-data">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21092 次 |
| 最近记录: |