-2

Possible Duplicate:
jQuery Ajax File Upload

i want to upload a file using php and during the upload i want to show a loader to the user. Afterwards one div should be changed, and therefore i thought jQuery will be the right choice.

I tried it with this method, but it is not working properly:

HTML:

<div id="pop_layerbody">
<form action="javascript:;" method="post" enctype="multipart/form-data" onSubmit="jsUploadFile();">
<input name="bild" id="bild" type="file" size="50" maxlength="100000">
<input type="submit" value="Hochladen" id="button_upload">
</form>
</div>

JavaScript/JQuery:

function jsUploadFile() {
    $('#pop_layerbody').html('<img src="../includes/images/ajax-loader-big.png" style="margin-top:35px;" />');
    $.ajax({
        type: "POST",
        url: "upload_picture_logic.php",
    }).done(function (msg) {
        alert("Data Saved: " + msg);
    });
}

PHP: (excerpt)

@move_uploaded_file($_FILES['bild']['tmp_name'], "upload/".$_FILES['bild']['name']);

Anybody know the answer? It seems that even the POST-combination between HTML and JS is not working...

1

1 Answer 1

2

You can not upload file asynchronous with ajax. You can however fake that behavior with various jquery plugins for file uploading.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.