0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 3.129.63.214


Current Path : /var/www/website/nublr/admin/
Upload File :
Current File : /var/www/website/nublr/admin/index.js

$("#select").on("click", function () {
  var file_data = $("#upload").prop("files")[0];
  var form_data = new FormData();
  form_data.append("file", file_data);
  // console.log(file_data);
  // return;

  $.ajax({
    url: "upload.php",
    dataType: "text",
    cache: false,
    contentType: false,
    processData: false,
    data: form_data,
    type: "post",
    success: function (response) {
      var response = JSON.parse(response);
      console.log(response);
      insertdata(response.uploadedfile);

      alert(response.msg);
      // if (response.err_code == 0) {
      //   alert(response.msg);
      //   insertdata(response.uploadedfile);
      //   return;
      // } else {
      //   alert("error while uploading file");
      //   return;
      // }
    },
  });
});

function insertdata(file_name) {
  var upload_home = document.getElementById("home").checked;
  var upload_exam = document.getElementById("exam").checked;
  var upload_notify = document.getElementById("notify").checked;

  var str = "";
  if (upload_home == true) {
    str += "home*";
  }
  if (upload_exam == true) {
    str += "exam*";
  }
  if (upload_notify == true) {
    str += "notify*";
  }
  console.log(file_name);
  var upload_type = str.slice(0, -1);

  var filename = document.getElementById("file_name").value;
  var fromdate = document.getElementById("fdate").value;
  var todate = document.getElementById("tdate").value;

  var uploadtype_split = upload_type.split("*");
  // console.log(uploadtype_split);
  // return;

  if (upload_type == 0) {
    alert("Please select Upload To...!");

    return;
  }

  if (filename == "") {
    alert("Please select File Name...!");
    document.getElementById("file_name").focus();

    return;
  }

  if (fromdate == "") {
    alert("Please select From Date...!");
    document.getElementById("fdate").focus();

    return;
  }

  if (todate == "") {
    alert("Please select To Date...!");
    document.getElementById("tdate").focus();

    return;
  }
  if (file_name > 0) {
    alert("Please Choose File...!");

    return;
  }

  var parameters =
    "&upload_type=" +
    upload_type +
    "&filename=" +
    filename +
    "&fromdate=" +
    fromdate +
    "&todate=" +
    todate +
    "&file_name=" +
    file_name;

  $.ajax({
    type: "post",
    url: "notif.php",
    data: parameters,
    success: function (response) {
      var response = JSON.parse(response);

      // console.log(response);
    },
  });
}