Laravel图像验证失败

时间:2017-03-14 02:18:50

标签: php validation laravel-5

此代码在我的本地但不在实时服务器上运行,在实时服务器上有些图像无法上传但有些图像可以但我无法看到图像之间的区别。

ini_set('memory_limit','512M');

$this->middleware('auth');

$this->validate($request, [
    'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:5120',
    'description' => 'required'
]);

$image_name = 'IMG'.time().'_'.rand(1000,9999);
$image_name_thumb = $image_name."_thumb";
$extension = ".".$request->image->getClientOriginalExtension();
$image_name_ext = $image_name.$extension;
$image_name_thumb_ext = $image_name_thumb.$extension;
$request->image->move(public_path('images/wall/'), $image_name_ext);
$img = Image::make(public_path('images/wall/'.$image_name_ext));
$img->resize(250, null, function ($constraint) { $constraint->aspectRatio();});
$img->save(public_path('images/wall/'.$image_name_thumb_ext));

这是

返回的错误消息
$errors->first('image')

"图片无法上传。"

0 个答案:

没有答案