本文整理匯總了PHP中Symfony\Component\HttpFoundation\File\UploadedFile::getFileInfo方法的典型用法代碼示例。如果您正苦於以下問題:PHP UploadedFile::getFileInfo方法的具體用法?PHP UploadedFile::getFileInfo怎麽用?PHP UploadedFile::getFileInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\HttpFoundation\File\UploadedFile
的用法示例。
在下文中一共展示了UploadedFile::getFileInfo方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createFromFile
/**
* Create a file row from the given file
* @param UploadedFile $file
* @return mixed
*/
public function createFromFile(UploadedFile $file)
{
$fileName = FileHelper::slug($file->getClientOriginalName());
$exists = $this->model->whereFilename($fileName)->first();
if ($exists) {
throw new \InvalidArgumentException('File slug already exists');
}
return $this->model->create(['filename' => $fileName, 'path' => "/assets/media/{$fileName}", 'extension' => $file->guessClientExtension(), 'mimetype' => $file->getClientMimeType(), 'filesize' => $file->getFileInfo()->getSize()]);
}
示例2: createFromFile
/**
* Create a file row from the given file
* @param UploadedFile $file
* @return mixed
*/
public function createFromFile(UploadedFile $file)
{
$fileName = FileHelper::slug($file->getClientOriginalName());
$exists = $this->model->whereFilename($fileName)->first();
if ($exists) {
$fileName = $this->getNewUniqueFilename($fileName);
}
return $this->model->create(['filename' => $fileName, 'path' => config('asgard.media.config.files-path') . "{$fileName}", 'extension' => substr(strrchr($fileName, "."), 1), 'mimetype' => $file->getClientMimeType(), 'filesize' => $file->getFileInfo()->getSize(), 'folder_id' => 0]);
}
示例3: createFromFile
/**
* Create a file row from the given file
* @param UploadedFile $file
* @return mixed
*/
public function createFromFile(UploadedFile $file)
{
$fileName = FileHelper::slug($file->getClientOriginalName());
$exists = $this->model->whereFilename($fileName)->first();
if ($exists) {
$fileName = $this->getNewUniqueFilename($fileName);
}
$data = ['filename' => $fileName, 'path' => config('asgard.media.config.files-path') . "{$fileName}", 'extension' => substr(strrchr($fileName, "."), 1), 'mimetype' => $file->getClientMimeType(), 'filesize' => $file->getFileInfo()->getSize(), 'folder_id' => 0];
if (is_module_enabled('Site')) {
$siteId = Site::id();
$data['site_id'] = $siteId;
$data['path'] = config('asgard.media.config.files-path') . '/' . Site::current()->slug . "/{$fileName}";
}
return $this->model->create($data);
}