Form :: file:如何使用Input :: old在验证错误和/或更新后重新填充?

Dro*_*ddy 4 php validation file-upload laravel-4

在我的PhotosController中,我试图修改编辑操作,以便它在Form :: file()输入字段中显示现有值(并且,如果验证失败,它将重新填充该字段).

if ($validation->passes())
{
        // saves the image on the FS and updates the db entry
}

    return Redirect::route('photos.edit')
        ->withInput(Input::all())
        ->withErrors($validation)
        ->with('message', 'There were validation errors.');
Run Code Online (Sandbox Code Playgroud)

上传过程工作正常,但是当我查看现有记录时,或者如果验证在创建时失败,则Form :: file不显示该值.我查看了api中的方法,它只接受名称和可选的选项数组.而FormBuilder类中的其他方法允许我们使用Input :: old()设置值.

我已经尝试将以下值传递给withInput,但它们一直无济于事:*Input :: all()*Input :: old()*Input :: except('photo_path')*Input :: get ( 'photo_path')

如何更新此项,以便在验证失败时,或者如果用户查看现有记录,Form :: file()方法将显示现有值?

我敢肯定,我忽略了一些非常简单的东西,因为我还没有找到其他人的问题......

Nee*_*ule 8

显然你不能.出于安全原因,浏览器不允许您在文件输入上设置值.

有两个silimar问题,而不是laravel相关但我认为答案可以帮助你:

使用PHP或JavaScript提交失败的表单后,您可以重新填充文件输入吗?

验证失败后恢复输入类型=文件的值