本文整理汇总了PHP中Symfony\Component\HttpFoundation\File\UploadedFile::getMimetype方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadedFile::getMimetype方法的具体用法?PHP UploadedFile::getMimetype怎么用?PHP UploadedFile::getMimetype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\File\UploadedFile
的用法示例。
在下文中一共展示了UploadedFile::getMimetype方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createVersionFromFile
/**
* @param AssetInterface $asset
* @param UploadedFile $file
*
* @return AssetVersion
*/
public function createVersionFromFile(AssetInterface $asset, UploadedFile $file)
{
list($width, $height) = getimagesize($file->getRealPath());
$extension = File::extension($file->getClientOriginalName(), $file->getMimetype());
$version = $this->version->create(['asset_id' => $asset->getId(), 'extension' => $extension, 'filesize' => $file->getClientSize(), 'filename' => $file->getClientOriginalName(), 'width' => $width, 'height' => $height, 'edited_at' => time(), 'edited_by' => Auth::getPerson()->getId(), 'mimetype' => $file->getMimeType(), 'metadata' => File::exif($file->getRealPath())]);
$file->move($asset->directory(), $version->id);
return $version;
}
示例2: preUpload
/**
* PrePersist()
*/
public function preUpload()
{
if (null === $this->getFile()) {
return;
}
try {
$this->setMimeType($this->file->getMimetype());
} catch (FileNotFoundException $e) {
$this->setMimeType($this->file->getClientMimeType());
}
// set the path property to the filename where you'ved saved the file
$filename = $this->sanitise($this->file->getClientOriginalName());
$this->setFilename($filename);
}