0

Before implementing AJAX the form was submitting, uploading the files and also sending the emails via PHP so I'm assuming there is some AJAX or PHP option that I'm missing. Any help or pointers would be greatly appreciated.

-

JQuery

    $('.form').submit(

        function(event) {

            var content = $(this).data('load'),
                url = $(this).attr('action');

            $.ajax({
               type: "POST",
               url: url,
               data: $(this).serialize(),
               processData: true,
               beforeSend: function() {

               },
               success: function(data) {    

                  $('.flex-inline').load(content, function() {

                     ajaxForms.init();

                  });           

               }
            });

            event.preventDefault();

    });

PHP

<?php

    $file_name = "video.mp4";

    $subject = 'X';
    $message = 'X';
    $headers = 'From: x@x.com' . "\r\n" .
    'Reply-To: x@x.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();        

    $target_dir = "uploads/";
    $target_file = $target_dir . basename($_FILES["video"]["name"]);
    $uploadOk = 1;
    $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));

    if ($uploadOk == 0) {

        echo "Sorry, your file was not uploaded.";

    } else {

        if (move_uploaded_file($_FILES["video"]["tmp_name"], $target_dir . $file_name)) {

            mail($_POST["email"], $subject, $message, $headers);

        }

}?>

0 Answers0