How to upload image using Ajax in PHP?
<p>I have a form</p>

<pre><code>&lt;form id="profile_imageform" class="image_form" enctype="multipart/form-data"&gt;

    &lt;fieldset&gt;
        &lt;div class="entry"&gt;
            &lt;label&gt;Filename:&lt;/label&gt;
            &lt;input type="file" name="file" id="file" /&gt;
        &lt;/div&gt;
    &lt;/fieldset&gt;
    &lt;div class="actions"&gt;
        &lt;button type="submit"&gt;Save &amp;amp; Close&lt;/button&gt;( &lt;a href="#/profile" class="cancel"&gt;Cancel&lt;/a&gt; )
    &lt;/div&gt;
&lt;/form&gt;
</code></pre>

<p>and my js file look like</p>

<blockquote>
  <p>ProfileForm.prototype.init = function(){
          var self = this;</p>
</blockquote>

<pre><code>    //Initialize properties
    this.view = $( "#profile_form_view" );
    this.imageForm = $( "#profile_imageform" );
    this.fields.id = this.imageForm.find( ":input[ name = 'id' ]" );
    this.fields.image = this.imageForm.find( ":input[ name = 'file' ]" );

    //Bind the submit handler
    this.imageForm.submit(function( event ){

        //Submit the form
        self.saveImage(this.fields.id.val(), this.fields.image.val());

        //Cancel default event
        return( false );

    });

 ProfileForm.prototype.saveImage = function( id, image, onSuccess, onError ){
    var self = this;

    application.ajax({
        url: "test.php",
        data: {
            method: "saveImage",
            id: id,
            image: image
        },
        success: function( response ){
            if (response.success){
                onSuccess( response.data );
            }else{
                onError( response.errors );
            }
        }

    });
};
</code></pre>

<p>but</p>

<pre><code>this.fields.image.val() 
</code></pre>

<p>returns the image name what i need is it's tmp_name.
Will it possible to get it's tmp_name at jQuery? If so how?</p>

<p>But this php code also returns error</p>

<pre><code>if (isset($_POST['method']))
{
    if (isset($_POST['image']))
    {
        echo $_FILES['image']['tmp_name'];
    }
}
</code></pre>
