教程截图
教程简介
为EMLOG体系侧边栏增添图床代码 本日我们用的是新浪接口不知道接口今后会不会和先算用着翻开侧边栏新建侧边栏复制我们的代码在保留 下来侧边栏设置显现这个侧边栏
新浪代码
<div class="momll"><style>momll-img{max-width:80%;display:block}#选图{position:absolute;z-index:1;cursor:pointer;opacity:0}#box,#选图{background:#b485e2;color:#FFF;display:block;height:40px;line-height:30px;text-align:center}</style><input type="file" id="选图"><div id="box">挑选或拖拽图象举行上传</div><img id="图片" style="width:100%"><p id="文本" style="word-wrap:break-word"></p><script src="https://www.mom1.cn/m1/mom11.js"></script><script>选图.onchange=function(){if(!this.files||!this.files[0])return alert('拔取文件失足!') var 图片文件=this.files[0]if(图片文件.type.indexOf('image')!=0)return alert('这不是一个图象或音频!') UP(图片文件,function(pid){ 文本.innerHTML= 图片.src='https://ww2.sinaimg.cn/large/'+pid+ '.jpg' },function(){ alert('上传文件失足了!') },function(进度){ 文本.innerHTML=进度*100+'%' })}</script></div><script>varUP=function(o,success,error,upload,x,file,A){ if(typeof success=='function') file=o; else{ if(!o.file) return console.log('并没有传入须要上传的文件') if(A=o.success) success=A if(A=o.upload) upload=A if(A=o.error) error=A } x=new XMLHttpRequest() x.open('POST','https://x.mouto.org/wb/x.php?up&_r='+Math.random(),1) if(upload) x.upload.onprogress=function(e){ upload(e.loaded/e.total) } x.onload=function(r){ r=JSON.parse(x.responseText) if(r.error&&error) return error(r.error) if(r.pid&&success) return success(r.pid) } x.send(file)}</script>
评论列表