国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
thinkphp + 美圖秀秀api 實(shí)現(xiàn)圖片裁切上傳,帶數(shù)據(jù)庫(kù)

思路:

1.數(shù)據(jù)庫(kù) 創(chuàng)建test2 創(chuàng)建表img,字段id,url,addtime

2.前臺(tái)頁(yè):

  1>我用的是bootstrap 引入必要的js,css

  2>引入美圖秀秀的js

3.后臺(tái):圖片上傳

直接上代碼

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>thinkphp+美圖接口,實(shí)現(xiàn)圖片上傳+裁切</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/bootstrap.css"></head>
    <style type="text/css">
    html, body { height:100%; overflow:hidden; }
    body { margin:0; }
</style>
<body>
    <div class="container">
        <div class="panel">
            <a rowspan="3" class="text-center" data-toggle="modal" data-target="#head">
                <notempty name="info">
                    <img id="img" src="{$info.url}" width="150px" class="img-rounded" />
                    <else/> <i class="glyphicon glyphicon-user" style="color:#6E6E6E; font-size:150px;"></i>
                </notempty>
            </a>
    </div>
</div>

<div class="modal fade" id="head" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <style>.modal-body object{ position:relative;}</style>
            <div class="modal-body">
                <div class="clearfix" style="position:absolute; width:100%; left:0px; right:0px;" >
                    <div id="altContent"></div>
                </div>
                <script src="__PUBLIC__/js/xiuxiu.js" type="text/javascript"></script>
                <script type="text/javascript">
                    window.onload=function(){
                           /*第1個(gè)參數(shù)是加載編輯器div容器,第2個(gè)參數(shù)是編輯器類型,第3個(gè)參數(shù)是div容器寬,第4個(gè)參數(shù)是div容器高*/
                        xiuxiu.embedSWF("altContent",5,"100%","400px",'headeditor');
                           //修改為您自己的圖片上傳接口
                        xiuxiu.setUploadURL("{:C('URL')}/index.php/Home/Upload/uploadImg.html");
                            xiuxiu.setUploadType(2);
                            //xiuxiu.setUploadDataFieldName("upload_file");
                        xiuxiu.onInit = function ()
                        {
                            xiuxiu.loadPhoto("{:C('URL')}{$info.url}");
                        }
                        xiuxiu.onBeforeUpload = function (data, id)
                        {
                          var size = data.size;
                          if(size > 2 * 1024 * 1024)
                          { 
                            alert("圖片不能超過(guò)2M"); 
                            return false; 
                          }
                          return true; 
                        }
                        xiuxiu.onUploadResponse = function (data)
                        {
                            //data=JSON.parse(data);
                            setTimeout(function(){
                                window.location.reload();
                            },1000);
                            //alert("上傳響應(yīng)" + data);  //可以開(kāi)啟調(diào)試
                        }
                        // 調(diào)試
                        /*xiuxiu.onDebug = function (data)
                        {
                            alert("錯(cuò)誤響應(yīng)" + data);
                        }*/
                    }
        </script>
            </div>
        </div>
    </div>
</div>

</body>
</html>

uploadcontroller.class.php

<?php
namespace Home\Controller;
use Think\Controller;
/**
* 圖片上傳
*/
class UploadController extends Controller
{
    // 圖片上傳
    public function uploadImg()
    {

        $upload = new \Think\Upload();// 實(shí)例化上傳類
        $upload->maxSize   =     3145728 ;// 設(shè)置附件上傳大小
        $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 設(shè)置附件上傳類型
        $upload->rootPath  =      './image/'; // 設(shè)置附件上傳目錄
        //$upload->savePath  =      'img/'; // 設(shè)置附件上傳目錄
            // 上傳文件
        $info   =   $upload->upload();
        if(!$info) {// 上傳錯(cuò)誤提示錯(cuò)誤信息
        $this->error($upload->getError());
        }else{// 上傳成功
            $where = array('id'=>1);
            foreach ($info as $file) {
                $savename = $upload->rootPath.$file['savepath'].$file['savename'];
                $msg = M('Img')->where($where)->find();
                if ($msg) {
                    $res = M('Img')->where($where)->setField('url',$savename);
                }else{
                    $data = array(
                        'id'      => 1,
                        'url'     => $savename,
                        'addtime' => time()
                        );
                    $res = M('Img')->add($data);
                }
                $this->ajaxReturn(array('img'=>$savename,'status'=>1));
            }
        }
    }

}

?>

下載完整demo,帶數(shù)據(jù)庫(kù)sql文件

 

美圖秀秀的詳細(xì)開(kāi)發(fā)文檔:http://open.web.meitu.com/wiki/

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Vue+Echarts構(gòu)建大數(shù)據(jù)可視化展示公司品牌項(xiàng)目分享
Web開(kāi)發(fā)利器推薦(二)
Bootstrap
Thinkphp 5.0版本整合微信掃碼支付接口,含模型驗(yàn)證異步通知等完整實(shí)例
bootstrap 模態(tài)框 傳值
模態(tài)框 modal.js
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服