-2

I try writing code using JavaScript The file sending technology AJAX

HTML code

<form action="" method="post" id="contact_form" enctype="multipart/form-data">
  <input type="text" name="name" id="name">
  <input type="text" name="email" id="email">
  <input type="file" name="cv" id="cv">
  <input type="submit" name="submit"  id="contacts_send">
</form>

JavaScript code

    jQuery(document).ready(function(){
    jQuery("#contacts_send").click(function(){ 
    $.ajax({
    type : 'POST',
    url : 'process_job.php',   
    dataType : 'json', 
    data: { cv : $('#cv').val()
    name : $('#name').val(),
    email : $('#email').val()},
    success: function () {
            alert("Data Uploaded: ");
            }
    });
})
})

I researched the internet I did not find a similar solution to my problem I tried this solution but it did not work How can I upload files asynchronously?

i want my code do like this http://www.jainaewen.com/files/javascript/jquery/iframe-post-form.html

Community
  • 1
  • 1
jirjawi
  • 1
  • 1
  • 3

1 Answers1

0

the issue that you might be having is that you are not getting the files as you should get and instead you are trying to just catch them as simple queryString objects.

Use this:

if ($_FILES["file"]["error"] > 0) {

And then run the code. It will work, since the code is going good!

Afzaal Ahmad Zeeshan
  • 15,669
  • 12
  • 55
  • 103