當前位置: 首頁>>代碼示例>>PHP>>正文


PHP File::getPathname方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpFoundation\File\File::getPathname方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::getPathname方法的具體用法?PHP File::getPathname怎麽用?PHP File::getPathname使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpFoundation\File\File的用法示例。


在下文中一共展示了File::getPathname方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Constructor.
  *
  * @param File $file A File instance
  */
 public function __construct(File $file)
 {
     if ($file instanceof UploadedFile) {
         parent::__construct($file->getPathname(), $file->getClientOriginalName(), $file->getClientMimeType(), $file->getClientSize(), $file->getError(), true);
     } else {
         parent::__construct($file->getPathname(), $file->getBasename(), $file->getMimeType(), $file->getSize(), 0, true);
     }
 }
開發者ID:sfblaauw,項目名稱:pulsar-uploader,代碼行數:13,代碼來源:FilesystemFile.php

示例2: sendContent

 /**
  * Sends the file using the encryption manager with the php://output internal stream
  */
 public function sendContent()
 {
     if (!$this->isSuccessful()) {
         parent::sendContent();
         return;
     }
     $this->encryptionManager->decryptFile($this->file->getPathname(), 'php://output', $this->fileSize);
 }
開發者ID:VincentChalnot,項目名稱:SidusEncryptionBundle,代碼行數:11,代碼來源:DecryptFileResponse.php

示例3: storeFile

 /**
  * Store a file and return the hash
  * @param  File $file
  * @return string $hash
  */
 public function storeFile(File $file)
 {
     $hash = md5_file($file->getPathname());
     if (!$this->fileSystem->exists($this->getPath($hash))) {
         $this->fileSystem->rename($file->getPathname(), $this->getPath($hash));
     }
     return $hash;
 }
開發者ID:stopfstedt,項目名稱:ilios,代碼行數:13,代碼來源:TemporaryFileSystem.php

示例4: setFile

 /**
  * Sets the file to stream.
  *
  * @param \SplFileInfo|string $file               The file to stream
  * @param string              $contentDisposition
  * @param bool                $autoEtag
  * @param bool                $autoLastModified
  *
  * @return BinaryFileResponse
  *
  * @throws FileException
  */
 public function setFile($file, $contentDisposition = null, $etag = false, $lastModified = true)
 {
     if (!$file instanceof File) {
         if ($file instanceof \SplFileInfo) {
             $file = new File($file->getPathname());
         } else {
             $file = new File((string) $file);
         }
     }
     if (!$file->isReadable()) {
         throw new FileException('File must be readable.');
     }
     $this->file = $file;
     if ($etag === true) {
         $this->setAutoEtag();
     } elseif (!empty($etag)) {
         $this->setEtag($etag);
     }
     if ($lastModified === true) {
         $this->setAutoLastModified();
     } elseif (!empty($lastModified)) {
         is_numeric($lastModified) && ($lastModified = '@' . $lastModified);
         $this->setLastModified(new \DateTime($lastModified));
     }
     if ($contentDisposition) {
         $this->setContentDisposition($contentDisposition);
     }
     return $this;
 }
開發者ID:unionbt,項目名稱:hanpaimall,代碼行數:41,代碼來源:BinaryFileResponse.php

示例5: getResponse

 /**
  * @param Closure $callback
  * @param InterventionRequest $interventionRequest
  * @return Response
  */
 public function getResponse(Closure $callback, InterventionRequest $interventionRequest)
 {
     try {
         $this->cacheFile = new File($this->cacheFilePath);
         $response = new Response(file_get_contents($this->cacheFile->getPathname()), Response::HTTP_OK, ['Content-Type' => $this->cacheFile->getMimeType(), 'Content-Disposition' => 'filename="' . $this->realImage->getFilename() . '"', 'X-Generator-Cached' => true]);
         $response->setLastModified(new \DateTime(date("Y-m-d H:i:s", $this->cacheFile->getMTime())));
     } catch (FileNotFoundException $e) {
         if (is_callable($callback)) {
             $image = $callback($interventionRequest);
             if ($image instanceof Image) {
                 $this->saveImage($image);
                 $this->cacheFile = new File($this->cacheFilePath);
                 if (null !== $this->dispatcher) {
                     // create the ImageSavedEvent and dispatch it
                     $event = new ImageSavedEvent($image, $this->cacheFile);
                     $this->dispatcher->dispatch(ImageSavedEvent::NAME, $event);
                 }
                 // send HTTP header and output image data
                 $response = new Response(file_get_contents($this->cacheFile->getPathname()), Response::HTTP_OK, ['Content-Type' => $image->mime(), 'Content-Disposition' => 'filename="' . $this->realImage->getFilename() . '"', 'X-Generator-First-Render' => true]);
                 $response->setLastModified(new \DateTime('now'));
             } else {
                 throw new \RuntimeException("Image is not a valid InterventionImage instance.", 1);
             }
         } else {
             throw new \RuntimeException("No image handle closure defined", 1);
         }
     }
     $this->initializeGarbageCollection();
     return $response;
 }
開發者ID:ambroisemaupate,項目名稱:intervention-request,代碼行數:35,代碼來源:FileCache.php

示例6: crawl

 /**
  * @param File $file
  * @return Sale[]
  */
 public function crawl(File $file)
 {
     $sales = [];
     $crawler = new Crawler(file_get_contents($file->getPathname()));
     /** @var $saleItem \DOMElement */
     foreach ($crawler->filterXPath('//Data/Items/Item') as $saleItem) {
         $saleObj = new Sale();
         $tag = $saleItem->getAttribute('Tag');
         $tagEntity = $this->getEm()->getRepository('AffiliateDashboardBundle:Tag')->findbyName($tag);
         if (!$tagEntity) {
             $tagEntity = new Tag();
             $tagEntity->setName($tag);
             $this->getEm()->persist($tagEntity);
             $this->getEm()->flush();
         }
         $saleObj->setAsin($saleItem->getAttribute('ASIN'));
         $saleObj->setCategory($saleItem->getAttribute('Category'));
         $saleObj->setDate(new \DateTime(date('Y-m-d H:i:s', $saleItem->getAttribute('EDate'))));
         $saleObj->setEarnings($this->parseFloat($saleItem->getAttribute('Earnings')));
         $saleObj->setLinkType($saleItem->getAttribute('LinkType'));
         $saleObj->setPrice($this->parseFloat($saleItem->getAttribute('Price')));
         $saleObj->setQty((int) $saleItem->getAttribute('Qty'));
         $saleObj->setRate($this->parseFloat($saleItem->getAttribute('Rate')));
         $saleObj->setRevenue($this->parseFloat($saleItem->getAttribute('Revenue')));
         $saleObj->setAffiliateTag($tagEntity);
         $saleObj->setSeller($saleItem->getAttribute('Seller') ?: null);
         $saleObj->setTitle($saleItem->getAttribute('Title'));
         $sales[] = $saleObj;
     }
     return $sales;
 }
開發者ID:klein0r,項目名稱:affiliate-dashboard,代碼行數:35,代碼來源:Xmlfile.php

示例7: createImage

 /**
  * Given a single File, assuming is an image, create a new
  * Image object containing all needed information.
  *
  * This method also persists and flush created entity
  *
  * @param File $file File where to get the image
  *
  * @return ImageInterface Image created
  *
  * @throws InvalidImageException File is not an image
  */
 public function createImage(File $file)
 {
     $fileMime = $file->getMimeType();
     if ('application/octet-stream' === $fileMime) {
         $imageSizeData = getimagesize($file->getPathname());
         $fileMime = $imageSizeData['mime'];
     }
     if (strpos($fileMime, 'image/') !== 0) {
         throw new InvalidImageException();
     }
     $extension = $file->getExtension();
     if (!$extension && $file instanceof UploadedFile) {
         $extension = $file->getClientOriginalExtension();
     }
     /**
      * @var ImageInterface $image
      */
     $image = $this->imageFactory->create();
     if (!isset($imageSizeData)) {
         $imageSizeData = getimagesize($file->getPathname());
     }
     $name = $file->getFilename();
     $image->setWidth($imageSizeData[0])->setHeight($imageSizeData[1])->setContentType($fileMime)->setSize($file->getSize())->setExtension($extension)->setName($name);
     return $image;
 }
開發者ID:pramoddas,項目名稱:elcodi,代碼行數:37,代碼來源:ImageManager.php

示例8: testGuessExtensionIsBasedOnMimeType

 public function testGuessExtensionIsBasedOnMimeType()
 {
     $file = new File(__DIR__ . '/Fixtures/test');
     $guesser = $this->createMockGuesser($file->getPathname(), 'image/gif');
     MimeTypeGuesser::getInstance()->register($guesser);
     $this->assertEquals('gif', $file->guessExtension());
 }
開發者ID:peintune,項目名稱:Ternado,代碼行數:7,代碼來源:FileTest.php

示例9: create

 /**
  * @param File $file
  *
  * @return NotImageGivenException
  */
 public static function create(File $file)
 {
     $msg = sprintf('File "%s" is not an image, expected mime type is image/*, given - ', $file->getPathname(), $file->getMimeType());
     $me = new static($msg);
     $me->failedFile = $file;
     return $me;
 }
開發者ID:modera,項目名稱:foundation,代碼行數:12,代碼來源:NotImageGivenException.php

示例10: setFile

 /**
  * @param File $file
  *
  * @return $this
  */
 public function setFile(File $file)
 {
     $this->file = $file;
     if ($file->getPathname()) {
         $this->filename = sha1(uniqid(mt_rand(), true)) . '.' . $file->guessExtension();
     }
     return $this;
 }
開發者ID:ranpafin,項目名稱:docty,代碼行數:13,代碼來源:SimpleFile.php

示例11: getProductImage

 /**
  * @return mixed
  * @VirtualProperty
  */
 public function getProductImage()
 {
     $filePath = __DIR__ . '/../../../web/productPhoto/' . $this->image;
     if (file_exists($filePath)) {
         $file = new File($filePath);
         return array('fileInfo' => array('type' => $file->getMimeType(), 'encodeType' => 'base64'), 'fileInBinary' => base64_encode(file_get_contents($file->getPathname())));
     }
     return null;
 }
開發者ID:sendello,項目名稱:testTask,代碼行數:13,代碼來源:ProductPhoto.php

示例12: testGuessExtensionWithReset

 /**
  * @requires extension fileinfo
  */
 public function testGuessExtensionWithReset()
 {
     $file = new File(__DIR__ . '/Fixtures/other-file.example');
     $guesser = $this->createMockGuesser($file->getPathname(), 'image/gif');
     MimeTypeGuesser::getInstance()->register($guesser);
     $this->assertEquals('gif', $file->guessExtension());
     MimeTypeGuesser::reset();
     $this->assertNull($file->guessExtension());
 }
開發者ID:saj696,項目名稱:pipe,代碼行數:12,代碼來源:FileTest.php

示例13: copyToCache

 /**
  * @param File $file
  * @param $namespace
  * @param $image_hash
  * @param $image_thumb
  * @return File
  */
 public function copyToCache(File $file, $namespace, $image_hash, $image_thumb)
 {
     $dest = $this->createDestinationPath($namespace, $image_hash, $image_thumb);
     umask(00);
     if (!@copy($file->getPathname(), $dest)) {
         $err = error_get_last();
         throw new FileException($err['message']);
     }
     return new File($dest);
 }
開發者ID:vlatosev,項目名稱:filebundle,代碼行數:17,代碼來源:ImageCacheManager.php

示例14: processImage

 /**
  * @return Image
  */
 public function processImage()
 {
     // create an image manager instance with favored driver
     $manager = new ImageManager(['driver' => $this->configuration->getDriver()]);
     $this->image = $manager->make($this->nativeImage->getPathname());
     foreach ($this->processors as $processor) {
         $processor->process($this->image);
     }
     return $this->image;
 }
開發者ID:ambroisemaupate,項目名稱:intervention-request,代碼行數:13,代碼來源:InterventionRequest.php

示例15: resizeAndSave

 /**
  * Resize user avatar from uploaded picture
  * @param \Symfony\Component\HttpFoundation\File\UploadedFile|\Symfony\Component\HttpFoundation\File\File $original
  * @param int $user_id
  * @param string $size
  * @throws \Exception
  * @return null
  */
 public function resizeAndSave($original, $user_id, $size = 'small')
 {
     $sizeConvert = ['big' => [400, 400], 'medium' => [200, 200], 'small' => [100, 100]];
     if (!array_key_exists($size, $sizeConvert)) {
         return null;
     }
     $image = new Image();
     $image->setCacheDir(root . '/Private/Cache/images');
     $image->open($original->getPathname())->cropResize($sizeConvert[$size][0], $sizeConvert[$size][1])->save(root . '/upload/user/avatar/' . $size . '/' . $user_id . '.jpg', 'jpg', static::COMPRESS_QUALITY);
     return null;
 }
開發者ID:phpffcms,項目名稱:ffcms,代碼行數:19,代碼來源:FormAvatarUpload.php


注:本文中的Symfony\Component\HttpFoundation\File\File::getPathname方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。