本文整理匯總了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);
}