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


PHP UploadedFile::getRealPath方法代码示例

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


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

示例1: orientate

 /**
  * Orientate the image.
  *
  * @param UploadedFile $file
  * @param              $orientation
  * @return UploadedFile
  */
 protected function orientate(UploadedFile $file, $orientation)
 {
     $image = imagecreatefromjpeg($file->getRealPath());
     switch ($orientation) {
         case 2:
             imageflip($image, IMG_FLIP_HORIZONTAL);
             break;
         case 3:
             $image = imagerotate($image, 180, 0);
             break;
         case 4:
             $image = imagerotate($image, 180, 0);
             imageflip($image, IMG_FLIP_HORIZONTAL);
             break;
         case 5:
             $image = imagerotate($image, -90, 0);
             imageflip($image, IMG_FLIP_HORIZONTAL);
             break;
         case 6:
             $image = imagerotate($image, -90, 0);
             break;
         case 7:
             $image = imagerotate($image, 90, 0);
             imageflip($image, IMG_FLIP_HORIZONTAL);
             break;
         case 8:
             $image = imagerotate($image, 90, 0);
             break;
     }
     imagejpeg($image, $file->getRealPath(), 90);
     return new UploadedFile($file->getRealPath(), $file->getClientOriginalName(), $file->getMimeType(), $file->getSize());
 }
开发者ID:AkibaTech,项目名称:files-module,代码行数:39,代码来源:FileRotator.php

示例2: convertFieldValueFromForm

 /**
  * {@inheritdoc}
  *
  * @param null|\Symfony\Component\HttpFoundation\File\UploadedFile $data
  */
 public function convertFieldValueFromForm($data)
 {
     if ($data === null) {
         return null;
     }
     return array("inputUri" => $data->getRealPath(), "fileName" => $data->getClientOriginalName(), "fileSize" => $data->getSize());
 }
开发者ID:eab-dev,项目名称:NetgenEzFormsBundle,代码行数:12,代码来源:Image.php

示例3: saveFile

 /**
  * {@inheritdoc}
  */
 public function saveFile(UploadedFile $uploadedFile, $fileName)
 {
     $stream = fopen($uploadedFile->getRealPath(), 'r+');
     $result = $this->filesystem->writeStream($this->getMediaBasePath() . '/' . $fileName . '.' . $uploadedFile->guessClientExtension(), $stream);
     fclose($stream);
     return $result;
 }
开发者ID:superdesk,项目名称:web-publisher,代码行数:10,代码来源:MediaManager.php

示例4: 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;
 }
开发者ID:robbytaylor,项目名称:boom-core,代码行数:14,代码来源:Asset.php

示例5: compress

 /**
  * @param UploadedFile $file
  * @return string
  */
 public function compress(UploadedFile $file)
 {
     $shell = new Exec();
     $command = new Command(sprintf($this->command, $file->getRealPath(), 'compressed'));
     $shell->run($command);
     if (!file_exists($file->getRealPath() . 'compressed')) {
         throw new \RuntimeException('No compressed Image created!');
     }
     return $file->getRealPath() . 'compressed';
 }
开发者ID:ingowalther,项目名称:image-minify-api,代码行数:14,代码来源:PngquantCompressor.php

示例6: processFile

 /**
  * Process image file, make it progressive
  * @param UploadedFile $file
  */
 public function processFile(UploadedFile $file)
 {
     $this->file = $file;
     foreach (self::$IMAGE_TYPES as $type) {
         if (in_array($this->file->getMimeType(), $type['mime_types'])) {
             $filePath = $this->file->getRealPath();
             $typeObject = new $type['class']($filePath);
             $typeObject->process();
             break;
         }
     }
 }
开发者ID:hellmark1990,项目名称:Test-progressive-image,代码行数:16,代码来源:ProgressiveManager.php

示例7: savePhoto

 /**
  * Save the profile photo
  * 
  * @param  \Symfony\Component\HttpFoundation\File\UploadedFile $file
  * @return Boolean 
  */
 public function savePhoto(UploadedFile $file)
 {
     if (!$file->isValid()) {
         return false;
     }
     try {
         $this->photo = md5_file($file->getRealPath());
         $this->save();
         Storage::disk()->put($this->photo, file_get_contents($file->getRealPath()));
         return true;
     } catch (\Exception $e) {
         Log::error('Failed saving photo to user\'s profile: ' . $e->getMessage());
         return false;
     }
 }
开发者ID:mcknight0219,项目名称:shopus,代码行数:21,代码来源:Profile.php

示例8: execute

 public function execute()
 {
     if ($this->photo->isValid()) {
         $name = sha1($this->user->getId() . $this->user->getLogin() . $this->user->getRegisteredAt() . time() . uniqid('ffdf'));
         $photoUploader = new PhotoFormatter($this->photo->getRealPath(), self::MINIMUM_SIZE, self::MAXIMUM_SIZE, $this->output);
         $old = $this->user->getAvatar();
         $photoUploader->setNewName($name);
         $photoUploader->loadAndScale(self::START_SIZE);
         $this->user->setAvatar($name);
         $this->repository->update($this->user);
         if (!empty($old)) {
             $photoUploader->removeOld($old, self::START_SIZE);
         }
     }
 }
开发者ID:zyxist,项目名称:cantiga,代码行数:15,代码来源:UserProfilePhotoIntent.php

示例9: getFileMd5Name

 public function getFileMd5Name(UploadedFile $file)
 {
     $ext = $file->guessExtension();
     $md5 = md5_file($file->getRealPath());
     $name = $md5 . '.' . $ext;
     return $name;
 }
开发者ID:wucdbm,项目名称:gallery-bundle,代码行数:7,代码来源:ImageManager.php

示例10: updateUserProfileImage

 /**
  * 회원의 프로필 이미지를 등록한다.
  *
  * @param UserInterface $user        프로필 이미지를 등록할 회원
  * @param UploadedFile  $profileFile 프로필 이미지 파일
  *
  * @return string 등록한 프로필이미지 ID
  */
 public function updateUserProfileImage(UserInterface $user, UploadedFile $profileFile)
 {
     $disk = array_get($this->profileImgConfig, 'storage.disk');
     $path = array_get($this->profileImgConfig, 'storage.path');
     $size = array_get($this->profileImgConfig, 'size');
     // make fitted image
     /** @var ImageManager $imageManager */
     $imageManager = call_user_func($this->imageManagerResolver);
     $image = $imageManager->make($profileFile->getRealPath());
     $image = $image->fit($size['width'], $size['height']);
     // remove old profile image
     if (!empty($user->profileImageId)) {
         $file = File::find($user->profileImageId);
         if ($file !== null) {
             try {
                 $this->storage->remove($file);
             } catch (\Exception $e) {
             }
         }
     }
     // save image to storage
     $id = $user->getId();
     $file = $this->storage->create($image->encode()->getEncoded(), $path . "/{$id}", $id, $disk);
     return $file->id;
 }
开发者ID:xpressengine,项目名称:xpressengine,代码行数:33,代码来源:UserImageHandler.php

示例11: __construct

 /**
  * Create a new job instance.
  *
  * @param UploadedFile $image
  * @param null $filename (Without fileextension)
  * @param null $folder (Format: 'example/')
  */
 public function __construct(UploadedFile $image, $filename = null, $folder = null)
 {
     $this->realPath = $image->getRealPath();
     $this->extension = $image->getClientOriginalExtension();
     $this->filename = $this->getFilename($image, $filename);
     $this->folder = $folder;
 }
开发者ID:alcodo,项目名称:powerimage,代码行数:14,代码来源:CreateImage.php

示例12: doUpload

 /**
  * {@inheritDoc}
  */
 protected function doUpload(PropertyMapping $mapping, UploadedFile $file, $dir, $name)
 {
     $fs = $this->getFilesystem($mapping);
     $path = !empty($dir) ? $dir . '/' . $name : $name;
     $stream = fopen($file->getRealPath(), 'r+');
     $fs->writeStream($path, $stream, array('mimetype' => $file->getMimeType()));
 }
开发者ID:czifumasa,项目名称:Inzynierka5,代码行数:10,代码来源:FlysystemStorage.php

示例13: store

 public function store(UploadedFile $file)
 {
     $file->getClientOriginalName();
     $fileResult = \DB::table('file')->where('name', $file->getClientOriginalName())->where('checksum', md5_file($file->getRealPath()))->first();
     if (isset($fileResult->id)) {
         return $fileResult;
     }
     $fileResult = new Models\file();
     $fileResult->name = $file->getClientOriginalName();
     $fileResult->size = $file->getSize();
     $fileResult->mime_type = $file->getMimeType();
     $fileResult->checksum = md5_file($file->getRealPath());
     $fileResult->save();
     $fileResult->path = $this->moveFile($file, $fileResult->id);
     $fileResult->save();
     return $fileResult;
 }
开发者ID:moszkva,项目名称:fileuploader,代码行数:17,代码来源:Manager.php

示例14: uploadSingleFile

 /**
  * Upload a single file.
  *
  * @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
  *
  * @param string $target
  * @return string
  */
 protected function uploadSingleFile($file, $target = null)
 {
     $filename = uniqid() . '.' . $file->getClientOriginalExtension();
     $filename = $target ? $target . '/' . $filename : $filename;
     $content = file_get_contents($file->getRealPath());
     $this->flysystem->write($filename, $content);
     return cloudfront_asset($filename);
 }
开发者ID:xintang22,项目名称:Paxifi,代码行数:16,代码来源:S3UploaderProvider.php

示例15: saveUploadedFile

 /**
  * @param string $containerName
  * @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
  * @param string|null $relativePath
  *
  * @return bool
  */
 public function saveUploadedFile($containerName, UploadedFile $file, $relativePath)
 {
     if ($file->isValid() === false) {
         return false;
     }
     $fileName = $file->getClientOriginalName();
     $filePath = $this->getFullFileName($containerName, $fileName);
     return $this->move($file->getRealPath(), $filePath);
 }
开发者ID:project-a,项目名称:spryker-file-upload,代码行数:16,代码来源:Storage.php


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