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');