umeditor图片上传七牛云php,umeditor图片上传至七牛

确定图片上传实例化类的路径,查看umeditor/php/index.php

header("Content-Type:text/html;charset=utf-8");

error_reporting(E_ERROR | E_WARNING);

date_default_timezone_set("Asia/chongqing");

include "uploaderController.php"; //上传配置

$config = array(

"savePath" => "upload/", //存储文件夹

"maxSize" => 1000, //允许的文件最大尺寸,单位KB

"allowFiles" => array(".gif", ".png", ".jpg", ".jpeg", ".bmp") //允许的文件格式

); //实例化图片上传类

$up = new uploaderController("upfile", $config);

$type = $_REQUEST['type']; $callback = $_GET['callback'];

$info = $up->getFileInfo();

/**

* 返回数据

*/

if ($callback) {

echo '';

} else {

echo json_encode($info);

}

修改uploderController.php 上传类 upfile()

// $folder = $this->getFolder();

//不上传到本地

// if ( $folder === false ) { // $this->stateInfo = $this->getStateInfo( "DIR_ERROR" );

// return;

// }

// $this->fullName = $folder . '/' . $this->getName();

// if ( $this->stateInfo == $this->stateMap[ 0 ] ) {

// if ( !move_uploaded_file( $file[ "tmp_name" ] , $this->fullName ) ) {

// $this->stateInfo = $this->getStateInfo( "MOVE" );

// }

// }

//使用七牛上传

$result=$this->updateQiniu($file[ "tmp_name" ]);

$this->fullName='http://xxxxxxx.bkt.clouddn.com/'.$result['hash'];

实现updateQiniu() 方法

private function updateQiniu($tmp_name){

include '../../../../../vendor/qiniu/php-sdk/autoload.php'; //十分重要

$accessKey = 'xxxxxxxxx';

$secretKey = 'xxxxxxxxx';

$auth = new Auth($accessKey, $secretKey);

$bucket = 'ulala-test';

$token = $auth->uploadToken($bucket);

// 要上传文件的本地路径

$filePath =$tmp_name;

$uploadMgr =new UploadManager();

$key=null;

list($ret, $err) = $uploadMgr->putFile($token,$key, $filePath);

if ($err !== null) {

return $err;

} else {

//成功的返回数组 hash 和key

return $ret;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值