wenbobowen 4 năm trước cách đây
mục cha
commit
470b76dfa0
1 tập tin đã thay đổi với 11 bổ sung5 xóa
  1. 11 5
      src/components/input/normalArea.vue

+ 11 - 5
src/components/input/normalArea.vue

@@ -146,19 +146,25 @@ export default {
       return newStr
       return newStr
     },
     },
     uploadImg(imgData) {
     uploadImg(imgData) {
+      var bytes = window.atob(imgData.split(',')[1]);
+      var array = [];
+      for(var i = 0; i < bytes.length; i++){
+          array.push(bytes.charCodeAt(i));
+      }
+      var blob = new Blob([new Uint8Array(array)], {type: 'image/jpeg'});
+      var fd = new FormData();
+      fd.append('file', blob);
+      fd.append('innerPublic',true);
       const config = {
       const config = {
         headers: {
         headers: {
-          'Content-Type': 'application/json'
+          'Content-Type': 'multipart/form-data'
         },
         },
         withCredentials: false
         withCredentials: false
       } // 添加请求头
       } // 添加请求头
       return new Promise((resolve, reject) => {
       return new Promise((resolve, reject) => {
         axios.post(
         axios.post(
           '//star.xiaojukeji.com/upload/img.node',
           '//star.xiaojukeji.com/upload/img.node',
-          {
-            imgData,
-            'innerPublic': true
-          },
+          fd,
           config
           config
         ).then(res => {
         ).then(res => {
           console.log(res)
           console.log(res)