0
我有这样一段代码在我BaseModel的验证内部方法:无法验证文件上传在Laravel 4时请求AJAX
foreach(Input::file() as $key => $value)
{
(!empty($value)) ? $this->attributes[$key] = Input::file($key) : $this->attributes[$key] = '';
}
这让我文件验证,其余整合的输入验证。使用规则required
和mimes:png
它的工作原理应该如此。
但是,对于阿贾克斯请求,我总是收到$this->attributes[$key] = ''
。
在Laravel 4中通过ajax上传文件时有任何疑问吗?
我们可以看到您的上传脚本吗? – ryan0319
假设这是你的上传脚本,而不是Laravel。您不能简单地通过通常的ajax请求发送文件。 http://stackoverflow.com/questions/18706857/how-to-see-the-files-uploaded-in-a-form-with-ajax/18707003#18707003 –
好的弥敦道,你的信息回答我的问题。 – user2094178