php代码:
<?php
header("content-type: text/html; charset=utf-8");
require_once('./upyun.class.php');
$upyun = new upyun('空间', '账户', '密码');
$root = '根目录';
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
$s = ((float)$usec + (float)$sec);
return str_replace('.','',$s);
}
function fetch($u){
try {
global $upyun,$root;
$fh = file_get_contents($u);
//$fh = 'var newsclose = '.$fh;
$imgpath = $root.'/'.date('y').'/'.date('m').'/'.date('d').'/'.microtime_float().'.png';
//die();
$rsp = $upyun->writefile($imgpath, $fh, true); // 上传图片,自动创建目录
return $imgpath;
//fclose($fh);
}
catch(exception $e) {
echo $e->getcode();
echo $e->getmessage();
}
}
fetch('http://res.fuliqu.com/bbs/upload/forum/cj/2014/03/14/13947880739402.png');