作者 何书鹏
1 个管道 的构建 通过 耗费 0 秒

bug修改

... ... @@ -47,29 +47,20 @@ function createRoundImg($imgpath) {
}
/**
* 高效判断远程图片是否存在
* 判断远程文件是否存在
*/
function remoteImageExist($url)
{
// $exif_imagetype = [
// 1 => 'GIF',
// 2 => 'JPG',
// 3 => 'PNG',
// 4 => 'SWF',
// 5 => 'PSD',
// 6 => 'BMP',
// 7 => 'TIFF(intel byte order)',
// 8 => 'TIFF(motorola byte order)',
// 9 => 'JPC',
// 10 => 'JP2',
// 11 => 'JPX',
// 12 => 'JB2',
// 13 => 'SWC',
// 14 => 'IFF',
// 15 => 'WBMP',
// 16 => 'XBM'
// ];
$isExsit = @exif_imagetype($url);
if ($isExsit === false) return false;
return in_array($isExsit, [1, 2, 3]) ? true : false;
function url_exists($url) {
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
//不下载
curl_setopt($ch, CURLOPT_NOBODY, 1);
//设置超时
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($http_code == 200) {
return true;
}
return false;
}
\ No newline at end of file
... ...
... ... @@ -681,7 +681,7 @@ class User extends Api
{
$user = \app\api\model\User::get($this->auth->id);
empty($user['avatar']) && $this->error('请先上传头像');
!remoteImageExist($user['avatar']) && $this->error('头像失效,请更新头像');
!url_exists($user['avatar']) && $this->error('头像失效,请更新头像');
// 本地路径
$dir = 'uploads/user';
if (!file_exists($dir)){
... ...