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


PHP File::__construct方法代碼示例

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


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

示例1: __construct

 /**
  * {@inheritdoc}
  */
 public function __construct($path, $checkPath = true)
 {
     parent::__construct($path, $checkPath);
     if (false === strpos($this->getMimeType(), 'image')) {
         throw new \Exception(sprintf('Is not an image file. (%s)', $this->getMimeType()));
     }
 }
開發者ID:Antoad,項目名稱:GenemuFormBundle,代碼行數:10,代碼來源:Image.php

示例2: __construct

 public function __construct($path)
 {
     try {
         parent::__construct($path, true);
     } catch (SFFileNotFoundException $e) {
         throw new FileNotFoundException(sprintf('File %s not found', $path));
     }
 }
開發者ID:ilosada,項目名稱:chamilo-lms-icpna,代碼行數:8,代碼來源:File.php

示例3: __construct

 /**
  * @param string $path
  * @param bool   $checkPath
  *
  * @throws RuntimeException
  */
 public function __construct($path, $checkPath = true)
 {
     parent::__construct($path, $checkPath);
     if (0 !== strpos($this->getMimeType(), 'image/')) {
         $message = sprintf('File %s is not an image; Avalanche operates only on images', $path);
         throw new RuntimeException($message);
     }
 }
開發者ID:jmcclell,項目名稱:AvalancheImagineBundle,代碼行數:14,代碼來源:ImageFile.php

示例4: __construct

 /**
  * {@inheritdoc}
  */
 public function __construct($handle)
 {
     if (!is_resource($handle)) {
         throw new \RuntimeException('handle is not a resource');
     }
     $this->resource = $handle;
     $meta = stream_get_meta_data($handle);
     parent::__construct($meta['uri']);
 }
開發者ID:sidz,項目名稱:SonataMediaBundle,代碼行數:12,代碼來源:ApiMediaFile.php

示例5: __construct

 /**
  * {@inheritdoc}
  */
 public function __construct($path, $checkPath = true)
 {
     parent::__construct($path, $checkPath);
     if (false === strpos($this->getMimeType(), 'image')) {
         throw new \Exception(sprintf('Is not a image file. (%s)', $this->getMimeType()));
     }
     $format = $this->checkFormat($this->guessExtension());
     $generate = 'imagecreatefrom' . $format;
     $this->gd = new Gd();
     $this->gd->setResource($generate($this->getPathname()));
 }
開發者ID:hykz,項目名稱:Depot,代碼行數:14,代碼來源:Image.php

示例6: __construct

 /**
  * Constructs a new file from the given path.
  *
  * @param string|SplFileInfo $pathOrFile
  * @param string $original_name
  *
  */
 public function __construct($pathOrFile, $original_name)
 {
     $this->original_name = $original_name;
     if ($pathOrFile instanceof SplFileInfo) {
         parent::__construct($pathOrFile->getRealPath(), false);
     } elseif (is_string($pathOrFile)) {
         parent::__construct($pathOrFile, true);
     } else {
         throw new UnexpectedValueException('Input value must be string or SplFileInfo');
     }
 }
開發者ID:Somethingideally,項目名稱:generic-file,代碼行數:18,代碼來源:File.php

示例7: __construct

 /**
  * Accepts the information of the uploaded file as provided by the PHP global $_FILES.
  *
  * @param string  $path         The full temporary path to the file
  * @param string  $originalName The original file name
  * @param string  $mimeType     The type of the file as provided by PHP
  * @param integer $size         The file size
  * @param integer $error        The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants)
  * @param Boolean $test         Whether the test mode is active
  *
  * @throws FileException         If file_uploads is disabled
  * @throws FileNotFoundException If the file does not exist
  */
 public function __construct($path, $originalName, $mimeType = null, $size = null, $error = null, $test = false)
 {
     if (!ini_get('file_uploads')) {
         throw new FileException(sprintf('Unable to create UploadedFile because "file_uploads" is disabled in your php.ini file (%s)', get_cfg_var('cfg_file_path')));
     }
     $this->originalName = basename($originalName);
     $this->mimeType = $mimeType ?: 'application/octet-stream';
     $this->size = $size;
     $this->error = $error ?: UPLOAD_ERR_OK;
     $this->test = (bool) $test;
     parent::__construct($path);
 }
開發者ID:nightchiller,項目名稱:symfony,代碼行數:25,代碼來源:UploadedFile.php

示例8: __construct

 public function __construct($base64Content, $originalName, $mimeType = null, $size = null)
 {
     $this->originalName = $this->getName($originalName);
     $this->mimeType = $mimeType ?: 'application/octet-stream';
     $this->size = $size;
     $filePath = tempnam(sys_get_temp_dir(), 'streetartlas_');
     $file = fopen($filePath, 'wb');
     $data = explode(',', $base64Content);
     fwrite($file, base64_decode($data[1]));
     $meta_data = stream_get_meta_data($file);
     $path = $meta_data['uri'];
     fclose($file);
     parent::__construct($path, true);
 }
開發者ID:jahller,項目名稱:streetartlas,代碼行數:14,代碼來源:ApiUploadedFile.php

示例9: __construct

 public function __construct($realpath, $path)
 {
     $this->realpath = $realpath;
     parent::__construct($path, false);
 }
開發者ID:BozzaCoon,項目名稱:SPHERE-Framework,代碼行數:5,代碼來源:FakeFile.php

示例10: __construct

 /**
  * @param string $encoded
  * @param bool   $strict
  * @param bool   $checkPath
  */
 public function __construct($encoded, $strict = true, $checkPath = true)
 {
     parent::__construct($this->restoreToTemporary($encoded, $strict), $checkPath);
 }
開發者ID:hshn,項目名稱:base64-encoded-file,代碼行數:9,代碼來源:Base64EncodedFile.php

示例11: __construct

 /**
  * Constructs a new file from the given path.
  *
  * @param string $path      The path to the file
  * @param bool   $checkPath Whether to check the path or not
  *
  * @throws FileNotFoundException If the given path is not a file
  */
 public function __construct($path, $checkPath = true)
 {
     $this->getID3Info = new getID3();
     parent::__construct($path, $checkPath);
 }
開發者ID:redooor,項目名稱:redminportal,代碼行數:13,代碼來源:File.php

示例12: __construct

 public function __construct($root_path, $web_path)
 {
     $this->root_path = $root_path;
     $this->web_path = $web_path;
     parent::__construct($root_path . $web_path);
 }
開發者ID:it-blaster,項目名稱:uploadable-bundle,代碼行數:6,代碼來源:UploadableFile.php


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