|
@@ -190,10 +190,9 @@
|
|
|
//console.log("压缩后:" + base.length / 1024 + " " + base);
|
|
|
var bl = convertBase64UrlToBlob(base64Codes);
|
|
|
// formData.append('file', fileObj);
|
|
|
- console.log(fileObj);
|
|
|
+ // console.log(fileObj);
|
|
|
formData.append("file", bl); // 文件对象
|
|
|
- console.log(bl);
|
|
|
- console.log("file_" + Date.parse(new Date()) + ".jpg");
|
|
|
+ // console.log(bl);
|
|
|
that.uploadImg(formData);
|
|
|
});
|
|
|
},
|
|
@@ -429,50 +428,6 @@
|
|
|
return new Blob([u8arr], {type: mime});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- //上传文件方法
|
|
|
- // function UpladFile() {
|
|
|
- // var fileObj = document.getElementById("file").files[0]; // js 获取文件对象
|
|
|
- // var url = "后台图片上传接口"; // 接收上传文件的后台地址
|
|
|
- //
|
|
|
- // var form = new FormData(); // FormData 对象
|
|
|
- //
|
|
|
- // if (fileObj.size / 1024 > 1025) { //大于1M,进行压缩上传
|
|
|
- // photoCompress(fileObj, {
|
|
|
- // quality: 0.2
|
|
|
- // }, function (base64Codes) {
|
|
|
- // //console.log("压缩后:" + base.length / 1024 + " " + base);
|
|
|
- // var bl = convertBase64UrlToBlob(base64Codes);
|
|
|
- // form.append("file", bl, "file_" + Date.parse(new Date()) + ".jpg"); // 文件对象
|
|
|
- // xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
|
|
|
- // xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。
|
|
|
- // xhr.onload = uploadComplete; //请求完成
|
|
|
- // xhr.onerror = uploadFailed; //请求失败
|
|
|
- //
|
|
|
- // xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】
|
|
|
- // xhr.upload.onloadstart = function () {//上传开始执行方法
|
|
|
- // ot = new Date().getTime(); //设置上传开始时间
|
|
|
- // oloaded = 0;//设置上传开始时,以上传的文件大小为0
|
|
|
- // };
|
|
|
- //
|
|
|
- // xhr.send(form); //开始上传,发送form数据
|
|
|
- // });
|
|
|
- // } else { //小于等于1M 原图上传
|
|
|
- // form.append("file", fileObj); // 文件对象
|
|
|
- // xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
|
|
|
- // xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。
|
|
|
- // xhr.onload = uploadComplete; //请求完成
|
|
|
- // xhr.onerror = uploadFailed; //请求失败
|
|
|
- //
|
|
|
- // xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】
|
|
|
- // xhr.upload.onloadstart = function () {//上传开始执行方法
|
|
|
- // ot = new Date().getTime(); //设置上传开始时间
|
|
|
- // oloaded = 0;//设置上传开始时,以上传的文件大小为0
|
|
|
- // };
|
|
|
- //
|
|
|
- // xhr.send(form); //开始上传,发送form数据
|
|
|
- // }
|
|
|
- // }
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|