全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 646|回复: 6

请问大佬这个单文件图床接口怎么改成自己的啊

[复制链接]
发表于 2019-1-26 23:38:37 | 显示全部楼层 |阅读模式
本帖最后由 aws 于 2019-1-26 23:45 编辑

据说无版权

因为不改的话,图传到谁的账号里去了我都不知道啊

  1. <!--
  2. 四合一图床上传,支持百度(2M)、搜狗(2M)、360(2M)、新浪(10M)图片上传
  3. 作者:hostloc       
  4. 博客:https://www.hostloc.com
  5. Apis:https://wiki.yum6.cn
  6. 声明:前端无版权,调用YoungxjApis接口
  7. -->
  8. <!DOCTYPE html>
  9. <html lang='zh-cn'>
  10. <head>
  11.         <meta charset='UTF-8'>
  12.         <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
  13.         <title>四合一图床上传 - Cdn图床,百度图床,新浪图床,360图床,搜狗图床</title>

  14.         <link rel='stylesheet' >
  15.         <script src="https://cdn.bootcss.com/jquery/3.3.0/jquery.min.js"></script>
  16.         <style>
  17.         html,body {height: 100%;margin: 0;padding: 0;}body {font-family: 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;align-items: center;display: flex;}a{text-decoration:none;}#container {max-width: 400px;flex-basis: 100%;margin: 0 auto;background: #FFF;border-radius: 10px;box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);-webkit-box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);overflow: hidden;}#container #hero-img {width: 100%;height: 200px;background: #007bff;}#container #profile-img {width: 160px;height: 160px;margin: -80px auto 0 auto;}#container #profile-img img {width: 100%;background: #FFF;border-radius: 50%;}#container #content {text-align: center;width: 320px;margin: 0 auto;padding: 0 0 50px 0;}#container #content h1 {font-size: 29px;font-weight: 500;margin: 30px 0 0 0;}#container #content p {font-size: 18px;font-weight: 400;line-height: 1.4;color: #666;margin: 15px 0 40px 0;}#container #content a {color: #CCC;font-size: 14px;margin: 0 10px;transition: color .3s ease-in-out;-webkit-transition: color .3s ease-in-out;line-height: 40px;}#container #content a:hover {color: #007bff;}.btn{background: none repeat scroll 0 0 #1BA1E2; border: 0 none; border-radius: 2px; color: #FFFFFF !important; cursor: pointer; font-family: "Open Sans","Hiragino Sans GB","Microsoft YaHei","WenQuanYi Micro Hei",Arial,Verdana,Tahoma,sans-serif; font-size: 14px;  padding: 6px 10%;}.btn:hover,.yanshibtn:hover{background: none repeat scroll 0 0 #9B59B6; border: 0 none; border-radius: 2px; color: #FFFFFF!important; cursor: pointer; font-family: "Open Sans","Hiragino Sans GB","Microsoft YaHei","WenQuanYi Micro Hei",Arial,Verdana,Tahoma,sans-serif; font-size: 14px; padding: 8px 10%;}
  18.         .imgType{display: none;}
  19.         #images img{width: 100%}
  20.         #imgurl input{width: 100%}
  21.         #imgurl,#progress{display: none;}

  22.         @-webkit-keyframes rotation{
  23.                 from {-webkit-transform: rotate(0deg);}
  24.                 to {-webkit-transform: rotate(360deg);}
  25.         }

  26.         .Rotation{
  27.                 -webkit-transform: rotate(360deg);
  28.                 animation: rotation 3s linear infinite;
  29.                 -moz-animation: rotation 3s linear infinite;
  30.                 -webkit-animation: rotation 3s linear infinite;
  31.                 -o-animation: rotation 3s linear infinite;
  32.         }

  33.         .img{border-radius: 250px;}
  34. </style>
  35. </head>
  36. <body>
  37.         <div id='container'>
  38.                 <div id='hero-img'>
  39.                 </div>
  40.                 <div id='profile-img'>
  41.                         <img src='https://ww2.sinaimg.cn/large/005BYqpggy1fxbboztih4j305k05kwef.jpg' id="imgLoading" class="Rotation img" title="显示与隐藏"/>
  42.                 </div>
  43.                 <div id='content'>
  44.                         <h2>四合一图床上传</h2>
  45.                         <h5>
  46.                                 百度图床-新浪图床-搜狗图床-360图床
  47.                         </h5>
  48.                         <div id="progress"><progress max="100" value="0" id="pg"></progress></div>
  49.                         <p class="imgType" id="imgType"></p>
  50.                         <form id="form1">
  51.                                 <a href='javascript:void(0)' id="baiduImg" onclick="update('baidu')" class="btn btn-default" rel='nofollow'>百度图床</a><a href='javascript:void(0)' id="SinaImg" onclick="update('sina')" class="btn btn-default" rel='nofollow'>新浪图床</a>
  52.                                 <a href='javascript:void(0)' id="sougouImg" onclick="update('sougou')" class="btn btn-default" rel='nofollow'>搜狗图床</a><a href='javascript:void(0)' id="soImg" onclick="update('so')" class="btn btn-default" rel='nofollow'>360 图床</a>
  53.                                 <input type="file" id="file" name="file" onchange="sc($('#imgType').attr('imgType'));" style="display:none" accept="image/*">
  54.                         </form>
  55.                         <div class="imgContent" id="imgContent">
  56.                                 <div id="images"></div>
  57.                                 <div id="imgurl">
  58.                                         <code>ImgUrl:</code>
  59.                                         <input onclick="oCopy(this)" value=""  id="Imgs_url">
  60.                                         <code>HtmlUrl:</code>
  61.                                         <input onclick="oCopy(this)" value=""  id="Imgs_html">
  62.                                         <code>Ubb:</code>
  63.                                         <input onclick="oCopy(this)" value=""  id="Imgs_Ubb">
  64.                                         <code>Markdown:</code>
  65.                                         <input onclick="oCopy(this)" value=""  id="Imgs_markdown">
  66.                                 </div>
  67.                         </div>

  68.                 </div>
  69.         </div>
  70. </body>
  71. <script type="text/javascript">
  72. /**
  73. * [url=home.php?mod=space&uid=32138]@act[/url]      sina
  74. * @version  1.2
  75. * @author  hostloc
  76. * @date     2018-11-17
  77. * @url      https://www.hostloc.com
  78. */

  79. function update(type){
  80.         $('#file').val('');
  81.         $('#imgType').attr({
  82.                 imgType: type,
  83.         });
  84.         file.click();

  85. }


  86. function sc(type){
  87.         if(!type){return false;}
  88.         var animateimg = $("#file").val();
  89.         $('#pg').val('0');
  90.         var imgarr=animateimg.split('\\');
  91.         var myimg=imgarr[imgarr.length-1];
  92.         var houzui = myimg.lastIndexOf('.');
  93.         var ext = myimg.substring(houzui, myimg.length).toUpperCase();  
  94.         var file = $('#file').get(0).files[0];
  95.         if(!file){return false;}
  96.         var fileSize = file.size;

  97.         switch(type){
  98.                 case 'sougou':
  99.                 var maxSize = 2097152;
  100.                 break;
  101.                 case 'baidu':
  102.                 var maxSize = 2097152;
  103.                 break;
  104.                 case 'so':
  105.                 var maxSize = 2097152;
  106.                 break;
  107.                 case 'sina':
  108.                 var maxSize = 10485760;
  109.                 break;
  110.                 default:
  111.                 var maxSize = 10485760;
  112.         }
  113.         if(ext !='.PNG' && ext !='.GIF' && ext !='.JPG' && ext !='.JPEG' && ext !='.BMP'){  
  114.                 parent.alert('文件类型错误,请上传图片类型');return false;  
  115.         }else if(parseInt(fileSize) >= parseInt(maxSize)){  
  116.                 parent.alert('上传的文件不能超过'+maxSize/1024/1024+'MB');return false;  
  117.         }else{
  118.                 $('#imgLoading').attr('src','https://ww2.sinaimg.cn/large/005BYqpgly1fxbbemsqxaj305k05k3yg.jpg');
  119.                 var data = new FormData($('#form1')[0]);  
  120.                 var YoungxjApisToken = 'f07b711396f9a05bc7129c4507fb65c5';
  121.                 switch(type){
  122.                         case 'sougou':
  123.                         var apiUrl = 'https://apis.yum6.cn/api/5bd7f16aa33d7';
  124.                         break;
  125.                         case 'baidu':
  126.                         var apiUrl = 'https://apis.yum6.cn/api/5bd828881f92b';
  127.                         break;
  128.                         case 'so':
  129.                         var apiUrl = 'https://apis.yum6.cn/api/5bd90750c3f77';
  130.                         break;
  131.                         case 'sina':
  132.                         var apiUrl = 'https://apis.yum6.cn/api/5bd44dc94bcfc';
  133.                         break;
  134.                         default:
  135.                         return false;
  136.                 };
  137.                 $('#progress').show();
  138.                 $.ajax({
  139.                         url: apiUrl+'?token='+YoungxjApisToken,   
  140.                         type: 'POST',   
  141.                         data: data,   
  142.                         dataType: 'JSON',
  143.                         processData: false,   
  144.                         contentType: false,
  145.                         xhr: function(){
  146.                                 var xhr = $.ajaxSettings.xhr();
  147.                                 if(onprogress && xhr.upload) {
  148.                                         xhr.upload.addEventListener("progress" , onprogress, false);
  149.                                         return xhr;
  150.                                 }
  151.                         }
  152.                 }).done(function(ret){
  153.                         if(ret['code']=='1'){

  154.                                 var img = '';var imgurl = '';
  155.                                 if(type!='sina'){var imgSrc = ret['data'];}else{var imgSrc = ret['data']['url'];}
  156.                                 img += '<img src="'+imgSrc+'" name="sinaimg" id="sinaimg">';
  157.                                
  158.                                 $('#Imgs_url').val(imgSrc);
  159.                                 $('#Imgs_html').val('<img src="'+imgSrc+'"/>');
  160.                                 $('#Imgs_Ubb').val('[img]'+imgSrc+'[/img]');
  161.                                 $('#Imgs_markdown').val('![]('+imgSrc+')');
  162.                                 $('#images').html(img);$('#imgLoading').attr('src','https://ww2.sinaimg.cn/large/005BYqpggy1fxbbgt35opj305k05k3yh.jpg');
  163.                                 $('#imgurl').show();
  164.                                 $('#progress').hide();  
  165.                         }else{
  166.                                 $('#progress').hide();
  167.                                 $('#imgLoading').attr('src','https://ww2.sinaimg.cn/large/005BYqpggy1fxbbey7nfuj305k05k3yg.jpg');
  168.                                 parent.alert(ret['msg']);
  169.                         }  
  170.                        
  171.                 });
  172.                 return false;  
  173.         }   
  174. }

  175. function onprogress(evt){
  176.         var loaded = evt.loaded;
  177.         var tot = evt.total;
  178.         var per = Math.floor(100*loaded/tot);
  179.         $('#pg').val(per);

  180. }
  181. function oCopy(obj){
  182.         obj.select();
  183.         document.execCommand("Copy");
  184.         if (browserRedirect()) {alert('设备类型为手机,有一定几率复制失败!请查看剪切板是否成功复制');}
  185. }

  186. function browserRedirect(){
  187.         var sUserAgent = navigator.userAgent.toLowerCase();
  188.         var bIsIpad = sUserAgent.match(/ipad/i) == 'ipad';
  189.         var bIsIphone = sUserAgent.match(/iphone os/i) == 'iphone os';
  190.         var bIsMidp = sUserAgent.match(/midp/i) == 'midp';
  191.         var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == 'rv:1.2.3.4';
  192.         var bIsUc = sUserAgent.match(/ucweb/i) == 'web';
  193.         var bIsCE = sUserAgent.match(/windows ce/i) == 'windows ce';
  194.         var bIsWM = sUserAgent.match(/windows mobile/i) == 'windows mobile';
  195.         var bIsAndroid = sUserAgent.match(/android/i) == 'android';
  196.         if(bIsIpad || bIsIphone || bIsMidp || bIsUc7 || bIsUc || bIsCE || bIsWM || bIsAndroid ){
  197.                 return 1;
  198.         }
  199. };
  200. $(document).ready(function(){
  201.         $('#imgLoading').click(function() {$("#imgContent").toggle();});
  202. });
  203. </script>
  204. </html>
复制代码
发表于 2019-1-26 23:39:36 | 显示全部楼层
玩玩好了,。里面有API 没那么容易改自己。
发表于 2019-1-26 23:39:45 | 显示全部楼层
youngxj。。。这个博主我认识,你居然敢这样干
发表于 2019-1-26 23:42:10 来自手机 | 显示全部楼层
https://apis.yum6.cn/api/5bd90750c3f77
都在他这个远程接口里面了,改不了,得自己写
 楼主| 发表于 2019-1-26 23:43:24 | 显示全部楼层
sunnyhu 发表于 2019-1-26 23:39
youngxj。。。这个博主我认识,你居然敢这样干

声明
前端无版权,上传Js由Youngxj编写,调用YoungxjApis接口

原来这才是原创啊
https://www.youngxj.cn/565.html
 楼主| 发表于 2019-1-26 23:45:07 | 显示全部楼层
duyu 发表于 2019-1-26 23:42
https://apis.yum6.cn/api/5bd90750c3f77
都在他这个远程接口里面了,改不了,得自己写 ...

那我图片传哪去了都不知道啊
发表于 2019-1-27 09:20:18 | 显示全部楼层
712473912你可以加群问他要要看
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-11-27 22:08 , Processed in 0.067753 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表