Validating multiple file uploads with Laravel 4

后端 未结 4 1707
遥遥无期
遥遥无期 2021-02-06 17:22

How do I go about validating an array of uploaded files in Laravel 4? I\'ve set it in the form to allow multiple files, and I\'ve tested that the files exist in the Input::file(

4条回答
  •  名媛妹妹
    2021-02-06 17:55

    Well, I'm not exactly sure what was causing the error, but after playing around a bit with the validator, I figured out that I couldn't just pass all the files at once. Instead, I made a new array that associated each file with keys 'file0', 'file1', etc. Then I passed these to the validator and set rules for each one (using a foreach loop). Then the validator worked as expected. Still, it wasn't flexible enough for my needs and I ended up using a non-laravel solution.

提交回复
热议问题