layui playing file into block

layer.open ({
    Content: $ ( "# importBox") HTML ().
     , btn: [ 'confirm the import', 'download templates'] // can be an unlimited number of buttons
     , yes: function (index, layero) {
        // callback button
      IF (checkExcelFile ()) {
       Debugger
       var importUrl rootPath + = '/business/gj/importDwhjEexceFile.shtml';
       // var f_importForm = $ ( "# importForm");
       var File = document.getElementById ( 'importExcelFile' ) .files [0];
       var Debug = document.getElementById ( 'Debug');
        debug.innerHTML = 'file name' + file.name + '<br/>' + ' file size' + file.size + '< br /> ';
       var f_importForm_f = $ ( "# importExcelFile") [0];
       var fileObj_fs = f_importForm_f.files; // js acquired file object
       var fs = fileObj_fs [0];
       var file = $ ( "# importExcelFile ") [0] .files [0]; // get the file
                  IF (! || typeof FS (FS) == "undefined" fs.size || <= 0) {
                   msgd ( 'tips', 2,' Please select Excle file! ");
                      return;
                  }
                  var FormFile the FormData new new = ();
                  formFile.append (" Action ", importUrl);
                  formFile.append (" ImportFile ", fileObj); // Add file object
                
      var from_data = $ ( '# importForm') the serialize ();.
      lr.ajax ({
       type: "POST",
       Data: FormFile,
       URL: importUrl,
       contentType: to false, // and has been declared attribute enctype = "multipart / form-data"So here set false
       processData: false, // do not need to do data processing
       dataType: 'json', // where dataType is returned back to the data format of HTML, xml, json
       the async: true, // whether asynchronous
       cache: false, // if the cache settings, the default setting becomes true, when you need each time refresh need to perform database operations, then, need to be set to the to false
       success: function (data) {
        IF (data == 'the OK') {
         msgd ( 'saved successfully', 1 'save data successfully!');
        } the else IF ( == data 'NOT_DATA') {
         msgd ( "data error" 2, "data error! ');
        } the else {
         msgd (' error introduced excel ', 2' introduced excel error! ');
        }
       }
      });

Guess you like

Origin www.cnblogs.com/ywf520/p/11571768.html