Can I use jquery post with image uploads?
<p>I'm trying to use jquery to submit my form like so but it's not triggering anything in the functions.php file.  Do I need to do anything special with a multipart/form-data? Am I missing something?</p>

<p>HTML:</p>

<pre><code>&lt;form id="process_image_form" enctype="multipart/form-data" action="&lt;?php echo htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES); ?&gt;" method="post" &gt;
    &lt;input type="hidden" name="image_id1" id="image_id1" /&gt;
    &lt;table class="bordered-table"&gt;
        &lt;tbody&gt;                 
            &lt;tr&gt;
                &lt;td&gt;&lt;input name="file" type="file" id="file"/&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt; 
                &lt;td&gt;&lt;button type="submit" class="btn primary" data-loading-text="Uploading..." id="upload_profile_photo" name="upload_profile_photo"&gt;Upload&lt;/button&gt;&lt;/td&gt; 
            &lt;/tr&gt;
        &lt;/tbody&gt;
    &lt;/table&gt;
&lt;/form&gt;
</code></pre>

<p>Jquery call:</p>

<pre><code>$('#upload_profile_photo').click(function(e) {
   e.preventDefault();

    $.post('gallery/functions.php', $("#process_image_form").serialize(), function(status) {
        if (status.st) {
            alert("Photo Uploaded");
        }
    }, "json");
});
</code></pre>

<p>functions.php:</p>

<pre><code>if (isset($_POST['upload_profile_photo'])) {

    if (isset($_FILES['file']) &amp;&amp; $_FILES['file']['size'] &gt; 0) {

        //handle file upload
        $size = filesize($_FILES['file']['tmp_name']);
        if ($size &gt; $max_file_size * 1024 * 1024) {
            $res-&gt;error = '&lt;div class="alert-message error"&gt;Your image file is too large. Reduce its size and try uploading again.&lt;/div&gt;';
            echo json_encode($res);
            exit();
        }
        if ($res-&gt;error == "") {
            //process image
            $res = uploadImage($_FILES['file']['tmp_name'], $user_id);
            if ($res-&gt;st) {
                unlink($_FILES['file']['tmp_name']);
                $res-&gt;msg = '&lt;div class="alert-message success"&gt;Your profile photo was uploaded successfully!&lt;/div&gt;';
                echo json_encode($res);
                exit();
            }
        }
    }
    else {
        $res-&gt;error = '&lt;div class="alert-message error"&gt;Please select a photo to upload.&lt;/div&gt;';
        echo json_encode($res);
        exit();
    }
}
</code></pre>
