ajaxForm无法发布文件

What I'm trying to do

I have a form which is posted via ajaxForm. The form contains a file input field, however the data isn't being processed with the rest of the information in the POST.

The code

HTML Form

<form id="profilepicForm" action="user/profilepic.php" method="post" enctype="multipart/form-data">
    <input type="file" accept="image/gif, image/jpeg, image/png" name="file" />
    <input type="hidden" name="userid" value="<?php echo $_SESSION['user']['id'] ?>" />
    <input type="submit" value="Upload">
</form>

Javascript

var options = { 
    complete: function(response) {
        $("#profilepicMessage").html(response.responseText);
    },
    error: function(){
        $("#profilepicMessage").html("ERROR: unable to upload file");
    } 
};

$("#profilepicForm").ajaxForm(options);

PHP

$user_id    = $_POST['userid'];
$image      = $_FILES['file']['name'];

print_r($_POST);
exit;

What's happening

All that comes through is Array ( [userid] => 34 ), where 34 is my particular userid. Therefore I know that the form is being posted, but the file is not going through.

You'll have to look for something like uploadifive to manage that, for ajax can't currently handle file transfers

(this is not entirely true, there is ajax2 and html5 file api, but save yourself a problem, look for uploadifive).

You should look at global variable $_FILES.