跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 仅仅不到3KB的阿里图床源码
未分類
9 4 月 2020

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

师太 大佬有话说 :

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

本帖最后由 师太 于 2020-4-9 10:50 编辑

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

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

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

        https://ae01.alicdn.com/kf/U730af9689d924454b9a497af200c2b3eR.png

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

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

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

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

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

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

<script src="https://www.layuicdn.com/layui-v2.5.6/layui.js"></script>
<script>
layui.use([‘layer’, ‘form’, ‘upload’], function(){
var layer = layui.layer
,$ = layui.jquery
,form = layui.form
,upload = layui.upload;

upload.render({
    elem: ‘#upload’
    ,url: ‘upload.php’ //改成您自己的上传接口
    ,done: function(res){
      layer.msg(‘上传成功’);
      layui.$(‘#uploadDemoView’).removeClass(‘layui-hide’).find(‘img’).attr(‘src’,res.url);
      layui.$(‘#url’).html(res.url);
      //console.log(res)
    }
});
});
</script>
</body>
</html>

upload.php

<?php

$file = $_FILES[‘file’];
if (is_uploaded_file($file[‘tmp_name’]))
{
        $extension = pathinfo($file[‘name’])[‘extension’];
        $imgname = time().rand(100,1000).’.’.$extension;
        if (move_uploaded_file($file[‘tmp_name’], $imgname))
        {
                $data= array
                (
                        ‘scene’ => ‘aeMessageCenterV2ImageRule’,
                        ‘name’ =>$imgname,
                        ‘file’ => new CURLFile(realpath($imgname))
                );
                $res = json_decode(icurl(‘https://kfupload.alibaba.com/mupload’,$data));
                @unlink($imgname);
                if ($res->msg == 0)
                {
                        echo json_encode($res);
                }
        }
}

function icurl($url, $data){
        $ch = curl_init();
        curl_setopt($ch,CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        $res = curl_exec($ch);
        curl_close($ch);
        return $res;
}

poko 大佬有话说 :

前排绑定zsbd

Zeros 大佬有话说 :

前排,,,大佬nb:lol

Yrh 大佬有话说 :

绑定绑定 :lol:lol:lol zsbd

ncnc 大佬有话说 :

之前用过 放到主页的侧栏当小工具 不过感觉就我自己用 就删除了 :lol

流河旱树 大佬有话说 :

不错 找时间我也改一个玩玩:lol

mjsz 大佬有话说 :

自己用用挺好。。。。简单

h20 大佬有话说 :

还是太长了,我一个JSP就搞定了

jpfree 大佬有话说 :

大佬厉害啊,如何在WP里用呢

yushui 大佬有话说 :

不错,打一个自己玩玩

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具