Syera_1 0 Newbie Poster

i wish to send another field together with my FormData, so after i googled it, they said to add append to my form data, done it. but it did not send anything to db including the content of the file.

here is my code:-

$('#upload_csv').on("submit", function(e){  
          var data = new FormData(this);
         data.append('test_filename', file);

           });

            $.ajax({  
                 url:"uploadfileprocess",  
                 method:"POST",  
                 data:{data,data},  
                 contentType:false,           
                 cache:false,         
                 processData:false,      
                 success: function(data){ 
                        alert(data);
                      if(data=='Error1')  
                      {  
                           alert("Invalid File");  
                      }  
                      else if(data == "Error2")  
                      {  
                           alert("Please Select File");  
                      }  
                      else  
                      {  
                           $('#importfiletodb').html(data);  
                      }  
                 }  
            }) 

all the content and the file name should be able to save together when user click submit.

how to make the file name submitted together with the content?
when tested, it seems like it didnt send any data to my ajax. but i dont know why it didnt.
The "submit" there should be type of the field or id of the field?
Because the "submit" there right now referring to my field type.

p/s: this is my first time using ajax to upload file. Glad if you guys can help. Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.