title: Upload an image with ajax without using a form
body: <p>I know that form nesting is not a valid option for html5 (and generally for html) so I'd like to understand how can I do a file upload inside a form without using another form.</p>
  
  <p>I have a form where the user can choose one image from a dropdown. I'd like to give the user the ability to add another image on the fly while filling the form. The new image will be then added as an option to the dropdown and the user can choose it. </p>
  
  <p><strong>EDIT:</strong> when I say "choose an image from a dropdown" I mean that the images are stored on the server on a specific folder. In the dropdown I show the files name (stored in a db). Adding a new image to the folder will add it to the db to and will add the new image name to the select. But each select option will just be:</p>
  
  <pre><code>&lt;option value="id_from_db"&gt;Image_name_from_db&lt;/option&gt;
  </code></pre>
  
  <p>and the table in the db will have: id - name - path_to_file</p>
  
  <p>Usually I use the <a href="http://malsup.com/jquery/form/" rel="nofollow">jquery Form plugin</a> to upload the new image and this plugin looks for a form with the <code>&lt;input type="file"&gt;</code> tag to do the upload. Is there any chance to upload the image without the nested form? I was thinking about using an iframe but this looks like a crazy idea. The actual html structure looks like:</p>
  
  <pre><code>&lt;form&gt;
      //some more stuffs for the main form
      &lt;select name="image"&gt;
          &lt;option&gt;existing options&lt;/option&gt;
      &lt;/select&gt;
      &lt;form&gt;
          &lt;input type="file"&gt;
          &lt;button&gt;Upload file&lt;/button&gt;
      &lt;/form&gt;
      //some more stuffs for the main form
      &lt;button&gt;Submit form&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I have no issue posting the main form, I have no issue adding the new file as an option to the select. But this structure is not a valid html and will not work.</p>