title: Rails 3 Image upload form submitting with http instead of AJAX
body: <p>I am working on a form to submit it by AJAX instead of http. 
  This is the form : </p>
  
  <pre><code>    &lt;%= form_for(:image, :remote =&gt; true, :url =&gt; {:controller=&gt; 'questions',:action =&gt; 'upload'},:multipart =&gt; true) do |f| %&gt;
  
      &lt;%= f.file_field :image, :onchange =&gt; "$(this).parents('form').submit();"  %&gt;
  
      &lt;% end %&gt;
  </code></pre>
  
  <p>I have set the <code>:remote =&gt; true</code>  option above and submitting the form with an <code>onchange</code> event . I have the following code in controller : </p>
  
  <pre><code>def upload
  
       if request.xhr?
          @image = Image.new(params[:image])
          @image.save
  
              respond_to do |format|
                  format.js { render :layout=&gt;false }
             end
       else
             render :text =&gt; 'Request Wasnt AJAX'
       end
  end
  </code></pre>
  
  <p>My action renders the text everytime , the request does not seem to be AJAX style despite the remote tag being set (it appears correctly even in the final HTML). I can't figure out where I am going wrong with this . I have tested it in the latest browser version of FF and Chrome , so I don't think it's a browser issue. Any ideas ?</p>
  
  <p><strong>Update</strong> : I did some more debugging attempts . The issue is with the file field , if I replace the file field with text field , the request is AJAX (everything else remaining same) . But with a file field it always sends a non AJAX request.</p>
  
  <p><strong>Note : Overall objective is to upload an image via AJAX request, with the response rendering nothing, no HTML, no redirection, no reload of the page.</strong> </p>