title: Flutter - How to send multiple images in formdata
body: <p>I want to upload multiple images in flutter using dio and formData. What I did is I created a for loop for storing MultipartFile in an array and then I passed the array to the data of &quot;img[]&quot;. However, I cannot upload the image if I passed the array but it works perfectly fine if I upload a single image.</p>
  <p>Here's my code.</p>
  <pre><code> var arr = new List(3);
   
   for (var i=0; i &lt;_tryPath.length; i++) {
      arr[i] = await MultipartFile.fromFile(imageFile[i].path, filename: 
      imageFile[i].path.split('/').last, contentType: new MediaType('image','jpg'));
   };
  
   print('this is arr = $arr');
  
   FormData formData = new FormData.fromMap({
      &quot;name&quot;: &quot;Max&quot;,
      &quot;location&quot;: &quot;Paris&quot;,
      &quot;age&quot;: 21,
      &quot;img[]&quot;: arr,
   });
  
   // dio is in another class here in AuthService.
   AuthService().donateRegister(formData).then((val) async {
      print('successful');
      print(val.data);
   });
  </code></pre>
  <p>Can you help me uploading many images in formData? I also would like not to limit the MediaType. What will I do if I will also upload pdf/docu or jpg MediaType? I will appreciate your time and answer. Thank you!</p>