当前位置: 首页>>代码示例>>PHP>>正文


PHP SplFileInfo::getClientOriginalName方法代码示例

本文整理汇总了PHP中SplFileInfo::getClientOriginalName方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileInfo::getClientOriginalName方法的具体用法?PHP SplFileInfo::getClientOriginalName怎么用?PHP SplFileInfo::getClientOriginalName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SplFileInfo的用法示例。


在下文中一共展示了SplFileInfo::getClientOriginalName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: name

 /**
  * @param \SplFileInfo $file
  *
  * @return string
  */
 public function name(\SplFileInfo $file)
 {
     if ($file instanceof UploadedFile) {
         return $this->escape($file->getClientOriginalName());
     }
     return parent::name($file);
 }
开发者ID:atom-azimov,项目名称:uploader-bundle,代码行数:12,代码来源:BasenameNamer.php

示例2: getFileExtension

 /**
  * @param \SplFileInfo $fileInfo
  * @return mixed|string
  */
 private function getFileExtension(\SplFileInfo $fileInfo)
 {
     if ($fileInfo instanceof UploadedFile) {
         return pathinfo($fileInfo->getClientOriginalName(), PATHINFO_EXTENSION);
     }
     return $fileInfo->getExtension();
 }
开发者ID:da-vinci-studio,项目名称:file-bundle,代码行数:11,代码来源:FileReceiver.php

示例3: generate

 /**
  * Generate all the path data of a file. If the original file name exceeds 100 characters, it is truncated.
  * The file name is sanitized, and a unique ID is prepended.
  *
  * For example, a file called "this i#s the é file.txt'" will produce the following output:
  *   [
  *      'uuid'      => '2fd4e1c67a2d28fced849ee1bb76e7391b93eb12',
  *      'file_name' => '2fd4e1c67a2d28fced849ee1bb76e7391b93eb12_this_i_s_the___file.txt'
  *      'path'      => '2/f/d/4/',
  *      'path_name' => '2/f/d/4/2fd4e1c67a2d28fced849ee1bb76e7391b93eb12_this_i_s_the___file.txt',
  *   ]
  *
  * @param \SplFileInfo $file
  *
  * @return array
  */
 public function generate(\SplFileInfo $file)
 {
     $originalFileName = $file instanceof UploadedFile ? $file->getClientOriginalName() : $file->getFilename();
     $uuid = $this->generateUuid($originalFileName);
     $sanitized = preg_replace('#[^A-Za-z0-9\\.]#', '_', $originalFileName);
     if (strlen($sanitized) > 100) {
         $sanitized = sprintf('%s.%s', substr($sanitized, 0, 95), $file->getExtension());
     }
     $fileName = $uuid . '_' . $sanitized;
     $path = sprintf('%s/%s/%s/%s/', $uuid[0], $uuid[1], $uuid[2], $uuid[3]);
     $pathName = $path . $fileName;
     return ['uuid' => $uuid, 'file_name' => $fileName, 'path' => $path, 'path_name' => $pathName];
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:29,代码来源:PathGenerator.php

示例4: create

 /**
  * {@inheritdoc}
  */
 public function create(\SplFileInfo $rawFile, array $pathInfo, $destFsAlias)
 {
     if ($rawFile instanceof UploadedFile) {
         $size = $rawFile->getClientSize();
         $mimeType = $rawFile->getMimeType();
         $originalFilename = $rawFile->getClientOriginalName();
         $extension = $rawFile->getClientOriginalExtension();
     } else {
         $size = filesize($rawFile->getPathname());
         $mimeType = MimeTypeGuesser::getInstance()->guess($rawFile->getPathname());
         $originalFilename = $rawFile->getFilename();
         $extension = $rawFile->getExtension();
     }
     $file = new $this->fileClass();
     $file->setKey($pathInfo['path'] . $pathInfo['file_name']);
     $file->setGuid($pathInfo['guid']);
     $file->setMimeType($mimeType);
     $file->setOriginalFilename($originalFilename);
     $file->setSize($size);
     $file->setExtension($extension);
     $file->setStorage($destFsAlias);
     return $file;
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:26,代码来源:FileFactory.php


注:本文中的SplFileInfo::getClientOriginalName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。