全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

仅仅不到3KB的阿里图床源码

  [复制链接]
发表于 2020-4-9 10:37:03 | 显示全部楼层 |阅读模式
本帖最后由 师太 于 2020-4-9 10:50 编辑

        源码来自帖子:https://www.hostloc.com/thread-650301-1-1.html

        他那个前端好看是好看,复制有点问题,一点就打开了上传窗口,所以随便改了一下,大小不到3KB

        演示地址:http://400008.xyz/ali

       

直接上源码,下边两个文件保存到任意目录即可;

index.html
CSS那行被LOC吞了,https://www.layuicdn.com/layui-v2.5.6/css/layui.css

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta charset="utf-8">
  5.   <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  6.   <title>阿里图床丨师太</title>
  7.   <link rel="stylesheet" >
  8.   <style type="text/css">
  9.           body { margin: auto; max-width: 720px; word-wrap:break-word; }
  10.   </style>
  11. </head>
  12. <body>

  13. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  14.   <legend>拖拽上传</legend>
  15. </fieldset>

  16. <div class="layui-upload-drag" id="upload">
  17.   <i class="layui-icon"></i>
  18.   <p>点击上传,或将文件拖拽到此处</p>
  19. </div>

  20. <div class="layui-hide" id="uploadDemoView">
  21.         <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  22.           <legend>文件信息</legend>
  23.         </fieldset>
  24.         <img src="" alt="上传成功后渲染" style="max-width: 300px"><hr>
  25.         <span id="url"></span>
  26. </div>

  27. <script src="https://www.layuicdn.com/layui-v2.5.6/layui.js"></script>
  28. <script>
  29. layui.use(['layer', 'form', 'upload'], function(){
  30.   var layer = layui.layer
  31.   ,$ = layui.jquery
  32.   ,form = layui.form
  33.   ,upload = layui.upload;

  34.   upload.render({
  35.     elem: '#upload'
  36.     ,url: 'upload.php' //改成您自己的上传接口
  37.     ,done: function(res){
  38.       layer.msg('上传成功');
  39.       layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src',res.url);
  40.       layui.$('#url').html(res.url);
  41.       //console.log(res)
  42.     }
  43.   });
  44. });
  45. </script>
  46. </body>
  47. </html>
复制代码


upload.php

  1. <?php

  2. $file = $_FILES['file'];
  3. if (is_uploaded_file($file['tmp_name']))
  4. {
  5.         $extension = pathinfo($file['name'])['extension'];
  6.         $imgname = time().rand(100,1000).'.'.$extension;
  7.         if (move_uploaded_file($file['tmp_name'], $imgname))
  8.         {
  9.                 $data  = array
  10.                 (
  11.                         'scene' => 'aeMessageCenterV2ImageRule',
  12.                         'name' =>$imgname,
  13.                         'file' => new \CURLFile(realpath($imgname))
  14.                 );
  15.                 $res = json_decode(icurl('https://kfupload.alibaba.com/mupload',$data));
  16.                 @unlink($imgname);
  17.                 if ($res->msg == 0)
  18.                 {
  19.                         echo json_encode($res);
  20.                 }
  21.         }
  22. }


  23. function icurl($url, $data){
  24.         $ch = curl_init();
  25.         curl_setopt($ch,CURLOPT_HEADER, 0);
  26.         curl_setopt($ch, CURLOPT_URL, $url);
  27.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  28.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  29.         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  30.         curl_setopt($ch, CURLOPT_POST, 1);
  31.         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  32.         $res = curl_exec($ch);
  33.         curl_close($ch);
  34.         return $res;
  35. }
复制代码
发表于 2020-4-9 18:41:08 | 显示全部楼层
那个帖子楼主已修复无法复制的问题
新版演示地址 https://img.wang/ali/
发表于 2020-4-9 10:37:35 | 显示全部楼层
前排绑定zsbd
发表于 2020-4-9 10:46:29 | 显示全部楼层
前排,,,大佬nb

点评

3kb大佬的确牛逼  发表于 2020-4-9 16:57
发表于 2020-4-9 10:47:57 | 显示全部楼层
绑定绑定 zsbd
发表于 2020-4-9 10:52:24 | 显示全部楼层
之前用过 放到主页的侧栏当小工具 不过感觉就我自己用 就删除了
发表于 2020-4-9 10:54:26 | 显示全部楼层
不错 找时间我也改一个玩玩
发表于 2020-4-9 10:54:54 | 显示全部楼层
自己用用挺好。。。。简单
发表于 2020-4-9 10:55:46 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2020-4-9 10:56:39 | 显示全部楼层
大佬厉害啊,如何在WP里用呢
发表于 2020-4-9 10:57:27 | 显示全部楼层
不错,打一个自己玩玩
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-26 10:39 , Processed in 0.068695 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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