mercredi 29 avril 2020

hasFile() is giving false for array of file object in controller Laravel

In the front end I having a loop with input type file with name as img_logo[$key] (of the loop) like:

<input type="file" name="img_logo[$key]" class="dropzone" id="" data-index="" >

After submitting the form it goes in the controller, there hasFile() giving true for img_logo but giving false for internal arrays.

I am stuck here only why this is happening, where I am getting it wrong. Although you can see the array's element is also a file object but hasFile() giving them false. Please guide me here I am having an array of files with key, value pair as mentioned below:

array:4 [▼

  "img_logo" => array:2 [▼
    1 => UploadedFile {#462 ▼
      -test: false
      -originalName: "Quotefancy-101003-3840x2160.jpg"
      -mimeType: "image/jpeg"
      -error: 0
      #hashName: null
      path: "/tmp"
      filename: "phpGbtonF"
      basename: "phpGbtonF"
      pathname: "/tmp/phpGbtonF"
      extension: ""
      realPath: "/tmp/phpGbtonF"
      aTime: 2020-04-29 17:59:37
      mTime: 2020-04-29 17:59:37
      cTime: 2020-04-29 17:59:37
      inode: 1078432563
      size: 754605
      perms: 0100600
      owner: 1155
      group: 1157
      type: "file"
      writable: true
      readable: true
      executable: false
      file: true
      dir: false
      link: false
    }
    3 => UploadedFile {#464 ▶}
  ]
]


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2yXDrac
via IFTTT

Aucun commentaire:

Enregistrer un commentaire