postController中Input::all()的“dd”输出:
array(8) {
["_token"]=>
string(40) "6WZ87M1LCiVCsaUS9HbjZckRibXfF2RP69LCpW7K",
...
...
["svg"]=>
object(Symfony\Component\HttpFoundation\File\UploadedFile)#9 (7) {
["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
bool(false)
["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
string(39) "Screenshot from 2013-06-18 17:07:27.png"
["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
string(9) "image/png"
["size":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
int(29747)
["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
int(0)
["pathName":"SplFileInfo":private]=>
string(14) "/tmp/phpdRTDU7"
["fileName":"SplFileInfo":private]=>
string(9) "phpdRTDU7"
}
}
验证:
$rules = array('svg' => 'required');
$check = Validator::make(Input::except('_token'), $rules);
if($check->fails()){
return Redirect::back()->withErrors($check);
}else{
return Redirect::back()->with('message', 'No problem');
}
我收到错误消息:
错误消息:svg 字段是必需的。
即使我上传了您在 dd 输出中看到的文件,它也始终显示该错误。
谢谢,