/* 在原有的编辑器基础上增加图片上传到cdn的功能*/
header(content-type: text/html; charset=utf-8);
error_reporting( e_error | e_warning );
$path = ./images/; /* 设置文件的存储路径 */
$ymd = date(y).date(m).date(d); //文件路径格式
$file_save_url=$path.$ymd./; //本地存储路径
$save_url= $ymd. /; //优盘云存储路径
include upyun.class.php;//引入优盘云处理类
include upyun_config.php;//优盘云配置
//实例化优盘云
$upyun = new upyun($img_bucketname, $img_username, $img_password);
try {
$file=$file_save_url.$info['name'];// 本地路径加文件名
$con =$save_url.$info['name'];//优盘云路径加文件名
$opts = array( upyun::content_md5 => md5(file_get_contents($file)) );
$fh = fopen($file, rb);
// 上传图片,自动创建目录
$rsp = $upyun->writefile(/.$con, $fh, true, $opts);
fclose($fh);
} catch(exception $e) {
$filename = error_log.txt;
$errorcontent = image . date(y-m-d h:m:s) . . $e->getcode(). . $e->getmessage() . \r\n;
$handle = fopen($filename, 'a');
fwrite($handle, $errorcontent);
fclose($handle);
exit;
} 原文链接:http://www.lujianlong.com/?p=260
upyun.rar ( 4.56 kb 下载:4 次 )
