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


PHP UploadedFile::getBasename方法代码示例

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


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

示例1: storeFile

 public function storeFile(UploadedFile $file)
 {
     $hashedName = sha1($file->getBasename() . filemtime($file->getPath()));
     $extension = strtolower($file->getClientOriginalExtension());
     $finalName = $hashedName . '.' . $extension;
     while (file_exists($this->targetDirectory . DIRECTORY_SEPARATOR . $this->hashToLocation($finalName))) {
         $hashedName .= '1';
         $finalName = $hashedName . '.' . $extension;
     }
     $hashed = $this->hashToLocation($finalName);
     $directory = dirname($this->targetDirectory . DIRECTORY_SEPARATOR . $hashed);
     if (!is_dir($directory)) {
         $ret = mkdir($directory, 0777, true);
         if (!$ret) {
             throw new DiskAssetException('Cannot create a directory for uploading the files!');
         }
     }
     $file->move($directory, $hashed);
     return $finalName;
 }
开发者ID:zyxist,项目名称:cantiga,代码行数:20,代码来源:FileRepository.php

示例2: prepareUploadData

 /**
  * Returns an array of data for upload model
  *
  * @param UploadedFile $uploadedFile
  * @return array
  */
 protected function prepareUploadData(UploadedFile $uploadedFile)
 {
     return ['extension' => $uploadedFile->getExtension(), 'mimetype' => $uploadedFile->getMimeType(), 'size' => $uploadedFile->getSize(), 'name' => $uploadedFile->getBasename('.' . $uploadedFile->getExtension())];
 }
开发者ID:pb199486,项目名称:Transit,代码行数:10,代码来源:UploadService.php

示例3: setFileInfo

    /**
     * Extract the file information from the uploaded file, into the internal properties
     */
    private function setFileInfo()
    {
        if ($this->file === null) {
            return;
        }

        if ($this->file instanceof \Symfony\Component\HttpFoundation\File\UploadedFile) {
            //load file information
            $fileInfo  = pathinfo($this->file->getClientOriginalName());
            $extension = $fileInfo['extension'];
            $name      = $fileInfo['filename'];

        } else {
            $extension = $this->file->guessExtension();
            $name      = $this->file->getBasename();
        }

        //set the file type using the type mapping
        if (array_key_exists(strtolower($extension), $this->typeMapping)) {
            $this->type = $this->typeMapping[strtolower($extension)];
        } else {
            $this->type = self::TYPE_UNKNOWN;
        }

        // The filesize in bytes.
        $this->fileSize  = $this->file->getSize();
        $this->name      = $this->removeSpecialCharacters($name);
        $this->extension = $extension;
        $this->path = str_replace(Shopware()->OldPath(), '', $this->getUploadDir() . $this->getFileName());

        if (DIRECTORY_SEPARATOR !== '/') {
            $this->path = str_replace(DIRECTORY_SEPARATOR, '/', $this->path);
        }
    }
开发者ID:nhp,项目名称:shopware-4,代码行数:37,代码来源:Media.php

示例4: upload

 public function upload(UploadedFile $file)
 {
     $fileName = $file->getBasename('.' . $file->getExtension()) . '.' . $file->guessExtension();
     $file->move($this->targetDir, $fileName);
     return $fileName;
 }
开发者ID:franiglesias,项目名称:milhojas,代码行数:6,代码来源:FileUploader.php

示例5: 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;
 }
开发者ID:picolit,项目名称:bbs,代码行数:64,代码来源:ArticleService.php

示例6: attachFile

 /**
  * @param string $key multi-part form item key name
  * @param string $filepath path to file
  * @param string|null $mimetype file mimetype, if none provided, will be guess from filepath
  * @param string|null $clientName optionnal client filename, if none provided, basename of filepath will be used
  */
 public function attachFile($key, $filepath, $mimetype = null, $clientName = null)
 {
     $clientName = $clientName ? $clientName : basename($filepath);
     $file = new File($filepath, true);
     $file = new UploadedFile($file->getRealPath(), $clientName, $file->getBasename(), $file->getMimeType(), $file->getSize(), 0);
     $this->getRequest()->files->set($key, $file);
 }
开发者ID:bogeux,项目名称:SimpleHttpBundle,代码行数:13,代码来源:Statement.php


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