Jump to content

File upload via AJAX


Pain

Recommended Posts

Hi there. I have to add a file upload facility to the form. Theres just one problem though - the form is submitted via AJAX.

$("#s_prop_full").validate({
    submitHandler: function (form) {
        $.ajax({
            type: "POST",
            url: "submit-proposal-full.php",
            data: $("#s_prop_full").serialize(),
beforeSend: function() {
       $('#loader3').fadeIn();
   },
complete: function(){
     $('#loader3').fadeOut();
 
   }
        }).done(function (msg) {
            $('#loader3').fadeOut();
 
 
$('#s_prop_full').fadeOut();
$('.s-form-full-thanks').fadeIn();
 
        });
    },
.....

It's pretty standard PHP after that:

 

 move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);

What do i have to add to the AJAX function? Thank you

Link to comment
https://forums.phpfreaks.com/topic/284139-file-upload-via-ajax/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.