本文整理汇总了PHP中Symfony\Component\HttpFoundation\File\UploadedFile::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadedFile::getType方法的具体用法?PHP UploadedFile::getType怎么用?PHP UploadedFile::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\File\UploadedFile
的用法示例。
在下文中一共展示了UploadedFile::getType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getExifReadData
/**
* @param UploadedFile $fileObject
* @return array
*/
private function getExifReadData(UploadedFile $fileObject)
{
Log::debug($fileObject->getPath());
Log::debug($fileObject->getFilename());
Log::debug($fileObject->getBasename());
Log::debug($fileObject->getClientMimeType());
Log::debug($fileObject->getExtension());
Log::debug($fileObject->getType());
$result = [];
$mimeType = $fileObject->getClientMimeType();
// upload_igm and thumbnail directory make
$dirName = date('Ym');
$uploadDir = public_path() . '/upload_img/' . $dirName;
$thumbnailDir = public_path() . '/thumbnail/' . $dirName;
$this->chkDir($uploadDir);
$this->chkDir($thumbnailDir);
//@todo オリジナル動画をリサイズする
$extension = explode('/', $fileObject->getClientMimeType())[1];
$newFileName = sha1($fileObject->getFilename() . time()) . '.' . $extension;
$saveFileName = $uploadDir . '/' . $newFileName;
$fileObject->move($uploadDir, $newFileName);
$thumbnail = Image::make(file_get_contents($saveFileName));
$thumbnail->resize(100, null, function ($constraint) {
$constraint->aspectRatio();
});
$thumbnail->save($thumbnailDir . '/' . $newFileName, 100);
$result['file_name'] = $dirName . '/' . $newFileName;
if ($mimeType !== 'image/jpeg') {
return $result;
}
$exif = exif_read_data($saveFileName);
if ($exif === false) {
return false;
}
$result['file_date_time'] = isset($exif['DateTimeOriginal']) ? $exif['DateTimeOriginal'] : null;
$result['file_size'] = $exif['FileSize'];
$result['mime_type'] = $exif['MimeType'];
$result['width'] = $exif['COMPUTED']['Width'];
$result['height'] = $exif['COMPUTED']['Height'];
$result['make'] = isset($exif['Make']) ? $exif['Make'] : null;
$result['model'] = isset($exif['Model']) ? $exif['Model'] : null;
$result['orientation'] = isset($exif['Orientation']) ? $exif['Orientation'] : null;
if (isset($exif["GPSLatitude"])) {
//緯度を60進数から10進数に変換
$lat = $this->convert_float($exif["GPSLatitude"][0]) + $this->convert_float($exif["GPSLatitude"][1]) / 60 + $this->convert_float($exif["GPSLatitude"][2]) / 3600;
//南緯の場合はマイナスにする
if ($exif["GPSLatitudeRef"] == "S") {
$lat *= -1;
}
//経度を60進数から10進数に変換
$lng = $this->convert_float($exif["GPSLongitude"][0]) + $this->convert_float($exif["GPSLongitude"][1]) / 60 + $this->convert_float($exif["GPSLongitude"][2]) / 3600;
//西経の場合はマイナスにする
if ($exif["GPSLongitudeRef"] == "W") {
$lng *= -1;
}
$result['lat'] = $lat;
$result['lng'] = $lng;
}
return $result;
}