首页 > Web开发 > 详细

ajax文件上传

时间:2020-06-05 17:54:39      阅读:43      评论:0      收藏:0      [点我收藏+]
softwarePackFileChange() {
      const fileTypes = "exe,rar,zip";
      const fileTypeArray = fileTypes.split(",");

      const softwarePackFile = $("#softwarePackFile").get(0).files[0];
      const filePathArray = softwarePackFile.name.toLowerCase().split(.);
      const fileType = filePathArray[filePathArray.length - 1];
      if (_.indexOf(fileTypeArray, fileType) == -1) {
        $WarnMessage(`支持的附件格式【${fileTypes}】,当前格式:${fileType}。`);
        return;
      }

      const formData = new window.FormData();
      formData.append("file", softwarePackFile);
      formData.append("versionId", this.versionId);
      formData.append("shelfId", this.shelfId);

       $.ajax({
         type: "POST",
         data: formData,
         contentType: false,
         processData: false,
         url: `${$$apiDevOpsPath}/uploadAppPkg`,
         success: response => {
           const message = response.message;
           if (message != undefined) {
             $WarnMessage(message);
           } else {
             const shelfVersionAppPkg = response.model;
             shelfVersionAppPkg.minioHost = response.host;
             this.$emit("pushAppSoftwarePackage", shelfVersionAppPkg);
           }
         },
       });
   
  }

 

ajax文件上传

原文:https://www.cnblogs.com/150536FBB/p/13050791.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!