【发布时间】:2015-04-14 14:03:52
【问题描述】:
我已经查看了我的代码一个小时了,但我真的找不到我的代码有什么问题。当我上传 3 张图片时,它只保存 2 张,而 4 张则保存 3 张,依此类推,所以这是我的代码:
控制器
if(Input::hasFile('images'))
{
$file = Input::file('images');
foreach($file as $files) {
$img = Image::make($files)->resize(300, 240);
$lgimg = Image::make($files);
$name = time().'-'.'chicken.jpg';
$img->save('images/chickens/thumbs/'.$name,30);
$lgimg->resize(800, null, function ($constraint) {
$constraint->aspectRatio();
});
$lgimg->save('images/chickens/'.$name,60);
$newimage = new Photo;
$newimage->chicken_id=$idinsert;
$newimage->photo_loc=$name;
$newimage->save();
}
}
观看次数
{{ Form::label('tuimg','Upload Image')}}
{{ Form::file('images[]', array('multiple'=>true)) }}
请帮忙。谢谢
【问题讨论】:
标签: php laravel eloquent image-uploading blade