Laravel 5-图像验证不起作用 [英] Laravel 5 - image validation doesn't work

查看:51
本文介绍了Laravel 5-图像验证不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Laravel 5 Validator来验证头像,我的规则如下:

I am using Laravel 5 Validator for validating avatars, my rules look like this:

$validator = Validator::make(
    Request::all(),
    [
        'avatar' => 'required|image|max:1000'
    ]
);

我正在尝试上传文件,并且总是显示未选择文件".如果我删除了必需的规则,那么它就可以了,甚至max:1000规则也可以.

I am trying to upload files and it always says "no file choosen". If I remove the required rule, then it works, even the max:1000 rule work.

推荐答案

确保该表单接受文件,

Form::open(array('url' => 'foo/bar', 'files' => true))

<form action="foo/bar" enctype="multipart/form-data">

这篇关于Laravel 5-图像验证不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆