if (!function_exists('uploadImg')) {
//上传图片
function uploadImg($url, $path = 'wx/fn/')
{
//$path = 'img/wechatapp/fn/'; 路径
if (!is_dir($path)){
$oldumask = umask(0);
mkdir($path, 0777,true);
umask($oldumask);
}
//对照片处理
$url = mb_substr($url, 0, -4);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
$file = curl_exec($ch);
curl_close($ch);
$filename = pathinfo($url, PATHINFO_BASENAME);
$filename = strtolower($filename);
$resource = fopen($path . $filename, 'a');
fwrite($resource, $file);
fclose($resource);
$name = $path . $filename;
return $name;
}
}
if (!is_dir($path)){ $oldumask = umask(0); mkdir($path, 0777,true); umask($oldumask); }
这边做处理。