我已经为multipleupload添加了我的代码:
public function upload(Request $request) {
$image = $request->file('file')->getClientOriginalName();
$filename = time().$image;
if(Input::hasFile('file')){
echo 'uploaded <br/>';
$file = Input::file('file');
$file->move('upload', $filename);
echo '<img src="upload/' . $filename .'"/>';
}
$gallery = new Gallery;
$gallery->image = $filename;
$gallery->save();
}
视图:
<form action="uploaded" method="post" enctype="multipart/form-data">
{{csrf_field()}}
<div class="form-group">
<input type="file" class="form-group" name="file[]" multiple>
</div>
<button type="submit" class="btn btn-primary">Add</button>
</form>
答案 0 :(得分:0)
虽然我不知道您的问题是什么,但我认为您应该将Input
更改为$request
。
像这样:
public function upload(Request $request){
$image = $request->file('file')->getClientOriginalName();
$filename = time().$image;
if($request->hasFile('file')){
echo 'uploaded <br/>';
$file = request->file('file');
$file->move('upload', $filename);
echo '<img src="upload/' . $filename .'"/>';
}
$gallery = new Gallery;
$gallery->image = $filename;
$gallery->save();
}