0

I am making a system where user can create a folder and upload intended file to it. I manage to get the file to upload, but when I try to pass array data & variable, it failed. I have try calling 2 ajax but I can't get the result I want. The file name & the array/variable data cannot be insert into mySql db.

Appreciate your kind help & thanks in advance.

var group = ["ALPHA", "BETA", "CHARLIE"];
var remark = $("input[name='h_remark']").val();

fd.append("file", document.getElementById("file_attach").files);

$.ajax({
    url: 'php/processfile.php',
    type: 'post',
    data: {
        fd,
        grouping: group,
        remark: remark
    },
    contentType: false,
    processData: false,
    success: function(response) {
        if (response === 'error') {
            alert("An error occur");
        } else if (response === 'fail') {
            alert("Fail to upload file");
        } else {
           alert("File uploaded");
        }
    },
});
Jeff
  • 59
  • 6

0 Answers0