本文整理汇总了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()));
}
}
示例2: __construct
public function __construct($path)
{
try {
parent::__construct($path, true);
} catch (SFFileNotFoundException $e) {
throw new FileNotFoundException(sprintf('File %s not found', $path));
}
}
示例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);
}
}
示例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']);
}
示例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()));
}
示例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');
}
}
示例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);
}
示例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);
}
示例9: __construct
public function __construct($realpath, $path)
{
$this->realpath = $realpath;
parent::__construct($path, false);
}
示例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);
}
示例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);
}
示例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);
}