Esempio n. 1
0
     $timeParam = date('Y/m/');
     if (file_exists(IMG_PATH_BASE . 'contact/' . $timeParam)) {
     } else {
         mkdir(IMG_PATH_BASE . 'contact/' . $timeParam, 0777, true);
     }
 }
 if (isset($_FILES['photo']) && $_FILES['photo']['error'] == 0) {
     $userId = $param['id'];
     $filePath = 'contact/' . $timeParam . $userId . '_' . md5_file($_FILES['photo']['tmp_name']) . '.' . end(explode('.', $_FILES['photo']['name']));
     $filePathSmall = 'contact/' . $timeParam . $userId . '_' . md5_file($_FILES['photo']['tmp_name']) . '_s' . '.' . end(explode('.', $_FILES['photo']['name']));
     #上传原图
     file_put_contents(IMG_PATH_BASE . $filePath, file_get_contents($_FILES['photo']['tmp_name']));
     #修正图片大小
     require_once 'lib/photo.class.php';
     $photoTool = new photo();
     $photoInfo = $photoTool->getPhotoInfo(IMG_PATH_BASE . $filePath);
     if ($photoInfo['width'] > 600) {
         $rate = $photoInfo['width'] / 600;
         $photoInfo['width'] = 600;
         $photoInfo['height'] = ceil($photoInfo['height'] / $rate);
     }
     #根据照片exif信息决定是否旋转
     require_once 'lib/exif.php';
     $exifInfo = GetImageInfo(IMG_PATH_BASE . $filePath);
     if ($exifInfo['方向'] == 'right side top') {
         $photoTool->flip(IMG_PATH_BASE . $filePath, IMG_PATH_BASE . $filePath, -90);
         $widthTmp = $photoInfo['width'];
         $photoInfo['width'] = $photoInfo['height'];
         $photoInfo['height'] = $widthTmp;
     }
     unset($exifInfo);