title: Passing blob(image) to php/laravel and getting input and saving
body: <p>User selects img with  file. I then dynamically create a form with data img from that selected file. and place it as source for  tag. Later when user presses submit I create a FormData object. And get a blob from DataUri.</p>
  
  <p>This is the code for finding the right img,it can have more then one.</p>
  
  <pre><code>var images = [];
  
  $('#imgDiv'+id+' img').each(function(index, img){
        images[index] = dataURItoBlob(img.src);
  });
  </code></pre>
  
  <p>And the dataURItoBlob function</p>
  
  <pre><code>function dataURItoBlob(dataURI) {
          var binary = atob(dataURI.split(',')[1]);
          var array = [];
          for(var i = 0; i &lt; binary.length; i++) {
              array.push(binary.charCodeAt(i));
          }
          return new Blob([new Uint8Array(array)], {type: 'image/*'});
      }
  </code></pre>
  
  <p>Then I append the img to formData.</p>
  
  <pre><code>formData.append('images[]',images);
  </code></pre>
  
  <p>and do this</p>
  
  <pre><code>var req = new XMLHttpRequest();
  req.open('post','/ads/add');
  req.send(formData);
  </code></pre>
  
  <p>And php side. Using laravel
  I tried this</p>
  
  <pre><code>$images = Input::file('images[]');
  </code></pre>
  
  <p>Returns null for me.
  Same for </p>
  
  <pre><code>$images = Input::file('images');
  </code></pre>
  
  <p>When i try this</p>
  
  <pre><code>$images = Input::get('images');
  </code></pre>
  
  <p>it returns as json response ["[object Blob]"]
  or as a dd() it returns </p>
  
  <pre><code>&lt;pre class='xdebug-var-dump' dir='ltr'&gt;
  &lt;b&gt;array&lt;/b&gt; &lt;i&gt;(size=1)&lt;/i&gt;
    0 &lt;font color='#888a85'&gt;=&amp;gt;&lt;/font&gt; &lt;small&gt;string&lt;/small&gt; &lt;font color='#cc0000'&gt;'[object Blob]'&lt;/font&gt; &lt;i&gt;(length=13)&lt;/i&gt;
  &lt;/pre&gt;
  </code></pre>
  
  <p>How could i then save it in for example /uploads/images/1</p>