title: Titanium Appcelerator Multi File upload
body: <blockquote>
    <p>I'm Developing with Appcelerator SDK 1.6.2 for iOS 4.3</p>
  </blockquote>
  
  <p>I'm trying to upload multiple files to a server, the problem is the number of files is dynamic and therefore cant be predetermined in the params of the XHR send.</p>
  
  <p>If I pass one file in it works fine but I cant seem to figure out how to pass in many.</p>
  
  <p>I've tried creating an array to hold the media elements but no dice.</p>
  
  <pre><code>var media = [];
  for(var i = 0; i &lt; sync.images.length; i++){
       media[i] = Titanium.Filesystem.getFile(sync.images[i].path).read();
  }
  
  xhr.send({
      media: media // no workie
  //  media: media[1] workie
  });
  </code></pre>
  
  <p>I found this article: <a href="http://developer.appcelerator.com/question/123794/multiple-file-upload-in-one-request" rel="nofollow">http://developer.appcelerator.com/question/123794/multiple-file-upload-in-one-request</a></p>
  
  <p>that assumes the following code should work:</p>
  
  <pre><code> xhr.send({      
       'media[]': imageFile.read(),
       'media[]': imageFile2.read()
   });
  </code></pre>
  
  <p>however i'm uncertain how to obtain this dynamically due to the fact that the number of images transferred can vary</p>
  
  <p>Suggestions would be great</p>