代码来自官方
uiUpload.add({ quality:1, onSuccess: function(file){ this.toBase64({ onSuccess: function (url) { $("#btnUpload").find('.span1').text('重新上传'); upload_pic(url); } }); } }) function upload_pic(base64){ var image = new Image(); image.src = base64; image.onload = function() { var resized = resizeUpImages(image); var severUrl = "/index.php/index/attachment/upload/dir/images/from/base64/module/bbs.html"; $.post(severUrl, {'imgBase64':resized,'Orientation':'','tags':''}).done(function (res) { if(res.code==1){ //console.log(res); var url = res.path; if(url.indexOf('://')==-1 && url.indexOf('/public/')==-1){ url = '/public/'+url; } $(".uselimg").html(''); $(".uqrcode").val(url); console.log(url) }else{ alert(res.info); } }).fail(function () { alert('操作失败,请跟技术联系'); }); } } function resizeUpImages(img) { //压缩的大小 var max_width = 1920; var max_height = 1080; var canvas = document.createElement('canvas'); var width = img.width; var height = img.height; if(width > height) { if(width > max_width) { height = Math.round(height *= max_width / width); width = max_width; } }else{ if(height > max_height) { width = Math.round(width *= max_height / height); height = max_height; } } canvas.width = width; canvas.height = height; var ctx = canvas.getContext("2d"); ctx.drawImage(img, 0, 0, width, height); //压缩率 return canvas.toDataURL("image/jpeg",0.72); }
请教一下:其中
var severUrl = "/index.php/index/attachment/upload/dir/images/from/base64/module/bbs.html";
这个地址有什么规律吗?或者说在有需要上传图片的页面,怎么找到图片的上传地址呢?感谢各位!