Procházet zdrojové kódy

轮播图上擦混

yf_zd před 5 roky
rodič
revize
126ba909ac
1 změnil soubory, kde provedl 25 přidání a 9 odebrání
  1. 25 9
      templates/backstageNet/systemSet/imageUpload.html

+ 25 - 9
templates/backstageNet/systemSet/imageUpload.html

@@ -210,7 +210,6 @@
                 </span>
             </div>
         </div>
-
         <!-- 内容 -->
         <div>
             <!-- 发布详情 -->
@@ -653,14 +652,17 @@
                 closeTailorA();
                 $('#testListAction').removeClass('testListAction')
                 $('#delTestData').removeClass('delTestData')
-                var arr = imgArrA.split(','), mime = arr[0].match(/:(.*?);/)[1]
-                bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
-                while (n--) {
-                    u8arr[n] = bstr.charCodeAt(n);
-                }
-                var imgFile = new File([u8arr], carouselName, { type: mime })
-                var form = new FormData()
-                form.append('upload', imgFile)
+                var fileObj = dataURLtoFile(imgArrA, $('#chooseImgA').val())
+				var form = new FormData();
+				form.append("upload", fileObj);
+                // var arr = imgArrA.split(','), mime = arr[0].match(/:(.*?);/)[1]
+                // bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
+                // while (n--) {
+                //     u8arr[n] = bstr.charCodeAt(n);
+                // }
+                // var imgFile = new File([u8arr], carouselName, { type: mime })
+                // var form = new FormData()
+                // form.append('upload', imgFile)
                 $.ajax({
                     url: 'system_photo',
                     type: 'post',
@@ -676,6 +678,20 @@
                 })
             }
         });
+        function dataURLtoFile(dataurl,filename) {
+			var arr = dataurl.split(',');
+			var mime = arr[0].match(/:(.*?);/)[1];
+			var bstr = atob(arr[1]);
+			var n = bstr.length;
+			var u8arr = new Uint8Array(n);
+			while (n--) {
+				u8arr[n] = bstr.charCodeAt(n);
+			}
+			//转换成file对象
+			return new File([u8arr], filename, { type: mime });
+			//转换成成blob对象
+			//return new Blob([u8arr],{type:mime});
+		}
         //首页轮播关闭裁剪框
         function closeTailorA() {
             $(".tailoring-container2").toggle();