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


PHP File::getRealPath方法代码示例

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


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

示例1: run

 public function run(File $file)
 {
     $image = $this->intervention->make($file->getRealPath());
     $image->orientate();
     $image->save(null, 100);
     $image->destroy();
 }
开发者ID:bmartel,项目名称:phperclip,代码行数:7,代码来源:FixRotation.php

示例2: process

 public function process(File $file, Image $image)
 {
     $imageData = $this->intervention->make($file->getRealPath());
     $imageData->brightness($this->brightness);
     $imageData->blur($this->blur);
     $imageData->save(null, $this->compression);
 }
开发者ID:tippingcanoe,项目名称:imager,代码行数:7,代码来源:Blur.php

示例3: downloadAction

 /**
  *
  * @param string $uid
  *
  * @return StreamedResponse|RedirectResponse
  */
 public function downloadAction($uid)
 {
     $urlFrom = $this->getReferer();
     if (null == $urlFrom || trim($urlFrom) == '') {
         $urlFrom = $this->generateUrl('_info_homepage');
     }
     $em = $this->getEntityManager();
     try {
         $biDoc = $em->getRepository('AcfDataBundle:BiDoc')->find($uid);
         if (null == $biDoc) {
             $logger = $this->getLogger();
             $logger->addError('Document inconnu');
             $this->flashMsgSession('warning', $this->translate('BiDoc.download.notfound'));
         } else {
             $biDocDir = $this->getParameter('kernel.root_dir') . '/../web/res/biDocs';
             $fileName = $biDoc->getFileName();
             try {
                 $dlFile = new File($biDocDir . '/' . $fileName);
                 $response = new StreamedResponse(function () use($dlFile) {
                     $handle = fopen($dlFile->getRealPath(), 'r');
                     while (!feof($handle)) {
                         $buffer = fread($handle, 1024);
                         echo $buffer;
                         flush();
                     }
                     fclose($handle);
                 });
                 $timestamp = $biDoc->getDtUpdate()->getTimestamp();
                 $response->headers->set('Content-Type', $biDoc->getMimeType());
                 $response->headers->set('Cache-Control', '');
                 $response->headers->set('Content-Length', $biDoc->getSize());
                 $response->headers->set('Last-Modified', gmdate('D, d M Y H:i:s', $timestamp));
                 $fallback = $this->normalize($biDoc->getTitle());
                 $contentDisposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $biDoc->getOriginalName(), $fallback);
                 $response->headers->set('Content-Disposition', $contentDisposition);
                 $biDoc->setNbrDownloads($biDoc->getNbrDownloads() + 1);
                 $em->persist($biDoc);
                 $em->flush();
                 return $response;
             } catch (FileNotFoundException $fnfex) {
                 $logger = $this->getLogger();
                 $logger->addError('Fichier introuvable ou autre erreur');
                 $logger->addError($fnfex->getMessage());
                 $this->flashMsgSession('error', $fnfex->getMessage());
                 $this->flashMsgSession('warning', $this->translate('BiDoc.download.notfound'));
             }
         }
     } catch (\Exception $e) {
         $logger = $this->getLogger();
         $logger->addCritical($e->getLine() . ' ' . $e->getMessage() . ' ' . $e->getTraceAsString());
         $this->flashMsgSession('error', $e->getMessage());
         $this->flashMsgSession('warning', $this->translate('BiDoc.download.notfound'));
     }
     return $this->redirect($urlFrom);
 }
开发者ID:sasedev,项目名称:acf-expert,代码行数:61,代码来源:BiDocController.php

示例4: import

 /**
  * @param File $file
  * @param Administration $administration
  * @return array
  *
  * @throws InvalidBankAccountException
  * @throws InvalidCurrencyException
  */
 public function import(File $file, Administration $administration)
 {
     $return = array();
     if (($handle = fopen($file->getRealPath(), "r")) !== FALSE) {
         while (($row = fgetcsv($handle)) !== FALSE) {
             $return[] = $this->createTransactionFromRow($row, $administration);
         }
         fclose($handle);
     }
     return $return;
 }
开发者ID:jaapjansma,项目名称:homefinance,代码行数:19,代码来源:AsnBankCsv.php

示例5: process

 public function process(File $file, Image $image, array $config = null)
 {
     $imageData = Intervention::make($file->getRealPath());
     $preserveRatio = $this->preserveRatio;
     $imageData->resize($this->width, $this->height, function ($constraint) use($preserveRatio) {
         if ($preserveRatio) {
             $constraint->aspectRatio();
         }
     });
     $imageData->save(null, 100);
 }
开发者ID:tippingcanoe,项目名称:imager,代码行数:11,代码来源:Resize.php

示例6: process

 public function process(File $file, Image $image, array $config = null)
 {
     $imageData = Intervention::make($file->getRealPath());
     // Sections override origin data.
     if ($this->section) {
         // ToDo: Add parameter to calculate crops by section.
         return;
     } else {
         $imageData->crop($this->width, $this->height, $this->originTop, $this->originLeft);
     }
     $imageData->save(null, 100);
 }
开发者ID:tippingcanoe,项目名称:imager,代码行数:12,代码来源:Crop.php

示例7: run

 public function run(File $file)
 {
     $image = $this->intervention->make($file->getRealPath());
     $preserveRatio = $this->preserveRatio;
     $image->resize($this->width, $this->height, function ($constraint) use($preserveRatio) {
         if ($preserveRatio) {
             $constraint->aspectRatio();
         }
     });
     $image->save(null, 100);
     $image->destroy();
 }
开发者ID:bmartel,项目名称:phperclip,代码行数:12,代码来源:Resize.php

示例8: fromFile

 /**
  * Creates a file object from a file on the disk.
  */
 public function fromFile($filePath)
 {
     if ($filePath === null) {
         return;
     }
     $file = new FileObj($filePath);
     $this->file_name = $file->getFilename();
     $this->file_size = $file->getSize();
     $this->content_type = $file->getMimeType();
     $this->disk_name = $this->getDiskName();
     $this->putFile($file->getRealPath(), $this->disk_name);
     return $this;
 }
开发者ID:mechiko,项目名称:staff-october,代码行数:16,代码来源:File.php

示例9: getImageThumb

 /**
  * @param File|null $image
  * @param $image_type
  * @return \Imagine\Image\ImageInterface
  */
 public function getImageThumb(File $image = null, $image_type, $image_area = null)
 {
     if (isset($this->image_types[$image_type])) {
         $source = $this->imagine->open($image->getRealPath());
         $this->preProcessSourceImg($source);
         $this->preProcessCropArea($source, $image_area);
         $type = $this->image_types[$image_type];
         $transformer_class = self::TRANSFORMER_CLASS_PATH . "\\" . Inflector::classify($type['transform']) . 'Transformer';
         $width = isset($type['width']) ? $type['width'] : null;
         $height = isset($type['height']) ? $type['height'] : null;
         /** @var $transformer TransformerInterface */
         $transformer = new $transformer_class($this->imagine, $source, $width, $height);
         $retval = $transformer->getTransformed();
     } else {
         throw new ResourceNotFoundException("Can't show image!");
     }
     return $retval->strip();
 }
开发者ID:vlatosev,项目名称:filebundle,代码行数:23,代码来源:ImageProcessor.php

示例10:

 function it_is_configurable(File $file)
 {
     $file->getRealPath()->willReturn('/path/to/file/img.jpg');
     $this->getFilePath()->shouldReturn(null);
     $this->isMultiple()->shouldReturn(false);
     $this->getCodeField()->shouldReturn('code');
     $this->isUploadAllowed()->shouldReturn(false);
     $this->setFilePath('/path/to/file/');
     $this->setMultiple(true);
     $this->setCodeField('custom_code');
     $this->setUploadAllowed(true);
     $this->getFilePath()->shouldReturn('/path/to/file/');
     $this->isMultiple()->shouldReturn(true);
     $this->getCodeField()->shouldReturn('custom_code');
     $this->isUploadAllowed()->shouldReturn(true);
     $this->setUploadedFile($file);
     $this->getFilePath()->shouldReturn('/path/to/file/img.jpg');
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:18,代码来源:YamlReaderSpec.php

示例11: uploadImage

 /**
  * Enregistre l'icône sur le disque.
  *
  * @return void
  */
 protected function uploadImage()
 {
     $this->deleteImage();
     $this->miniature = null;
     $fichier = new Fichier($this->imageFile->getRealPath());
     $this->image = $this->imageFile->getClientOriginalName();
     $this->dossier = $this->guessSousDossier();
     $fichier->move($this->getImageUploadDir() . DIRECTORY_SEPARATOR . $this->image, false);
     $image = new Image($fichier->getChemin());
     $image->setNomMinifie($this->getTitle(), '-', true, 128);
     $this->image = $image->getNom();
     if ($image->getLargeur() >= $image->getHauteur() && $image->getLargeur() > $this->getLargeurMaximale()) {
         $image->redimensionne($this->getLargeurMaximale(), null, true);
     } elseif ($image->getLargeur() < $image->getHauteur() && $image->getHauteur() > $this->getHauteurMaximale()) {
         $image->redimensionne(null, $this->getHauteurMaximale(), true);
     }
     $this->largeur = $image->getLargeur();
     $this->hauteur = $image->getHauteur();
     $this->setImageFile(null);
 }
开发者ID:lyssal,项目名称:collection-bundle,代码行数:25,代码来源:Illustration.php

示例12: fromFile

 public function fromFile($src, $target_quality = 90)
 {
     $imageFileName = strtok(str_replace(appHomeUrl() . '/storage/app/tmp/', '', $src), '?');
     if (startWith($imageFileName, self::getPrefix())) {
         $file = new File(storage_path('app/tmp/' . $imageFileName));
         if ($file) {
             $this->targetFileAsset = asset('storage/app/tmp/' . $imageFileName);
             $this->imageType = $file->getMimeType();
             $this->imageFilePath = $file->getRealPath();
             switch (strtolower($this->imageType)) {
                 case 'image/png':
                     $this->imageFileExt = 'png';
                     $this->image = imagecreatefrompng($this->imageFilePath);
                     break;
                 case 'image/gif':
                     $this->imageFileExt = 'gif';
                     $this->image = imagecreatefromgif($this->imageFilePath);
                     break;
                 case 'image/jpeg':
                 case 'image/pjpeg':
                     $this->imageFileExt = 'jpg';
                     $this->image = imagecreatefromjpeg($this->imageFilePath);
                     break;
                 default:
                     $this->saveResult(['success' => false, 'message' => 'Image type was not supported']);
                     return false;
             }
             $this->imageFileSize = $file->getSize();
             $this->targetQuality = $target_quality;
             list($imageWidth, $imageHeight) = getimagesize($this->imageFilePath);
             $this->imageWidth = $imageWidth;
             $this->imageHeight = $imageHeight;
             $this->targetFileName = $imageFileName;
             $this->targetFilePath = $this->imageFilePath;
             return true;
         }
     }
     $this->saveResult(['success' => false, 'message' => 'Image was not existed']);
     return false;
 }
开发者ID:linhntaim,项目名称:katniss,代码行数:40,代码来源:StoredPhoto.php

示例13: imageResize

 /**
  * imageResize
  *
  * @param File $file
  * @param int  $maxWidth
  * @param int  $maxHeight
  * @param bool $enlarge
  * @param bool $keepRatio
  *
  * @return ImageInterface|File|static
  */
 protected function imageResize(File $file, $maxWidth, $maxHeight, $enlarge = false, $keepRatio = true)
 {
     if ($maxWidth == 0 && $maxHeight == 0) {
         return $file;
     } elseif ($maxHeight == 0) {
         $maxHeight = $maxWidth;
     } elseif ($maxWidth == 0) {
         $maxWidth = $maxHeight;
     }
     $imagine = new Imagine();
     $resizeImg = $imagine->open($file->getRealPath());
     //get the size of the image you're resizing.
     $origHeight = $resizeImg->getSize()->getHeight();
     $origWidth = $resizeImg->getSize()->getWidth();
     if ($keepRatio) {
         //check for longest side, we'll be seeing that to the max value above
         if ($origHeight > $origWidth) {
             $newWidth = $maxHeight * $origWidth / $origHeight;
             $newHeight = $maxHeight;
         } else {
             $newHeight = $maxWidth * $origHeight / $origWidth;
             $newWidth = $maxWidth;
         }
     } else {
         $newWidth = $maxWidth;
         $newHeight = $maxHeight;
     }
     //dont enlarge small images
     if (!$enlarge) {
         if ($origHeight > $origWidth && $newHeight > $origHeight || $newWidth > $origWidth) {
             return $file;
         }
     }
     $size = new Box($newWidth, $newHeight);
     $resizeImg->resize($size)->save($file->getRealPath());
     return $file;
 }
开发者ID:rafrsr,项目名称:resource-bundle,代码行数:48,代码来源:ImageTransformer.php

示例14: __construct

 public function __construct(File $file, FFMpeg $ffmpeg)
 {
     $this->video = $ffmpeg->open($file->getRealPath());
 }
开发者ID:DraperStudio,项目名称:Laravel-Vidible,代码行数:4,代码来源:Meta.php

示例15: createImageRecord

 /**
  * Create the database entry for an image.
  *
  * @param File $image
  * @param array $attributes
  * @return Image
  */
 protected function createImageRecord(File $image, array $attributes = [])
 {
     // Obtain image metadata and save the record to the database.
     $imageData = new ImageData($image, $this->intervention->make($image->getRealPath()));
     $attributes = array_merge($attributes, ['width' => $imageData->getWidth(), 'height' => $imageData->getHeight(), 'average_color' => $imageData->getAveragePixelColor(), 'mime_type' => $image->getMimeType()]);
     return $this->imageRepository->create($attributes);
 }
开发者ID:tippingcanoe,项目名称:imager,代码行数:14,代码来源:Service.php


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