【发布时间】:2015-08-20 00:06:09
【问题描述】:
当我通过 jquery 提交表单后尝试验证图像文件时
$('#logo').submit();
我总是收到验证错误
The img field is required
这是我用来验证文件的验证
$input = array('img' => Input::file('img'));
$rules = array(
'img' => 'required',
);
// Now pass the input and rules into the validator
$validator = Validator::make($input, $rules);
// check if the validator failed -----------------------
if ($validator->fails()) {
// get the error messages from the validator
$messages = $validator->messages();
// redirect our user back to the form with the errors from the validator
print_r($messages);
}
我无法确定脚本有什么问题, 帮助我克服这个问题。 提前致谢。
【问题讨论】:
-
响应 print_r($_FILE); [img] => 数组 ([name] => PlottShana_1.jpg [type] => [tmp_name] => [error] => 1 [size] => 0)
-
你能发布你的javascript吗?
标签: jquery laravel file-upload laravel-4 laravel-validation