• <small id='0h0I3'></small><noframes id='0h0I3'>

      <bdo id='0h0I3'></bdo><ul id='0h0I3'></ul>
    <tfoot id='0h0I3'></tfoot>

    <i id='0h0I3'><tr id='0h0I3'><dt id='0h0I3'><q id='0h0I3'><span id='0h0I3'><b id='0h0I3'><form id='0h0I3'><ins id='0h0I3'></ins><ul id='0h0I3'></ul><sub id='0h0I3'></sub></form><legend id='0h0I3'></legend><bdo id='0h0I3'><pre id='0h0I3'><center id='0h0I3'></center></pre></bdo></b><th id='0h0I3'></th></span></q></dt></tr></i><div id='0h0I3'><tfoot id='0h0I3'></tfoot><dl id='0h0I3'><fieldset id='0h0I3'></fieldset></dl></div>
    <legend id='0h0I3'><style id='0h0I3'><dir id='0h0I3'><q id='0h0I3'></q></dir></style></legend>

      1. 如何在 laravel 5.3 中对多张图片上传进行验证

        时间:2024-08-14
          <tbody id='zkKCu'></tbody>

          <tfoot id='zkKCu'></tfoot>
          <legend id='zkKCu'><style id='zkKCu'><dir id='zkKCu'><q id='zkKCu'></q></dir></style></legend>

          • <bdo id='zkKCu'></bdo><ul id='zkKCu'></ul>

              <small id='zkKCu'></small><noframes id='zkKCu'>

                1. <i id='zkKCu'><tr id='zkKCu'><dt id='zkKCu'><q id='zkKCu'><span id='zkKCu'><b id='zkKCu'><form id='zkKCu'><ins id='zkKCu'></ins><ul id='zkKCu'></ul><sub id='zkKCu'></sub></form><legend id='zkKCu'></legend><bdo id='zkKCu'><pre id='zkKCu'><center id='zkKCu'></center></pre></bdo></b><th id='zkKCu'></th></span></q></dt></tr></i><div id='zkKCu'><tfoot id='zkKCu'></tfoot><dl id='zkKCu'><fieldset id='zkKCu'></fieldset></dl></div>
                2. 本文介绍了如何在 laravel 5.3 中对多张图片上传进行验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有意见

                      <input type="file" name="image[]" multiple="multiple" />
                  

                  和控制器功能

                  public function upload(Request $request)
                  {
                      $user_id = Auth::user()->id;
                  
                      foreach ($request->image as $image)
                      {
                          $this->validate($request,[
                          'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048'
                      ]);
                          $imageName = mt_rand() .time().'.'.$image->getClientOriginalExtension();
                          $img = Image::make($image->getRealPath());
                          $img->resize(100, 100, function ($constraint) {
                                                      $constraint->aspectRatio();
                                      })->save(public_path('images/thumbs').'/'.$imageName);
                          $image->move(public_path('images'), $imageName);
                      }
                  }
                  

                  但验证器总是给我错误

                      The image must be an image.
                  

                  推荐答案

                  将验证移出循环并尝试使用规则:

                  Move validation outside the loop and try with the rules:

                   'image' => 'required',
                   'image.*' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048'
                  

                  这篇关于如何在 laravel 5.3 中对多张图片上传进行验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:php框架中库和助手的区别 下一篇:什么是 PHP 框架,什么是好的框架?

                  相关文章

                        <bdo id='UKj5S'></bdo><ul id='UKj5S'></ul>

                      <small id='UKj5S'></small><noframes id='UKj5S'>

                    1. <i id='UKj5S'><tr id='UKj5S'><dt id='UKj5S'><q id='UKj5S'><span id='UKj5S'><b id='UKj5S'><form id='UKj5S'><ins id='UKj5S'></ins><ul id='UKj5S'></ul><sub id='UKj5S'></sub></form><legend id='UKj5S'></legend><bdo id='UKj5S'><pre id='UKj5S'><center id='UKj5S'></center></pre></bdo></b><th id='UKj5S'></th></span></q></dt></tr></i><div id='UKj5S'><tfoot id='UKj5S'></tfoot><dl id='UKj5S'><fieldset id='UKj5S'></fieldset></dl></div>

                      <tfoot id='UKj5S'></tfoot>

                    2. <legend id='UKj5S'><style id='UKj5S'><dir id='UKj5S'><q id='UKj5S'></q></dir></style></legend>