我想在 laravel-6.2 中上传图片,但显示“E:\xampp\tmp\php3A05.tmp”文件不存在或不可读。我的控制器功能:
$data = new Vedio();
if($request->hasFile('image')){
$files = $request->file('image');
$extension = $files->getClientOriginalExtension();
$fileName = str_random(5) . "-" . date('his') . "-" . str_random(3) . "." . $extension;
$folderpath = 'public/'.'Vedio/' . date('Y') . '/';
$image_url = $folderpath . $fileName;
$files->move($folderpath, $fileName);
// $data['topheadline_image'] = $image_url;
$data->image = $image_url;
}
$data->link=$request->link;
$data->title=$request->title;
$data->status=0;
$data->save();
return redirect('/admin-dashbord/Vedio-list')->with('success','Data saved in database successfully');
}
这是我的视图文件代码:这是我的视图文件代码:这是我的视图文件代码:这是我的视图文件代码:这是我的视图文件代码:
<form class="form-horizontal"action="{{url('/admin-dashbord/Vedio-post')}}" method="POST"enctype="multipart/form-data">
@csrf
<fieldset>
<div class="control-group">
<label class="control-label" for="focusedInput">Title</label>
<div class="controls">
<input class="input-xlarge " id="" name="title"type="text" value="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="focusedInput">Link</label>
<div class="controls">
<input class="input-xlarge " id="" name="link"type="text" value="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="focusedInput">Image</label>
<div class="controls">
<input class="input-xlarge " id="" name="image"type="file" value="">
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Save changes</button>
<button class="btn">Cancel</button>
</div>
</fieldset>
</form>