當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。