本文整理汇总了PHP中Nette\Http\IRequest::getFile方法的典型用法代码示例。如果您正苦于以下问题:PHP IRequest::getFile方法的具体用法?PHP IRequest::getFile怎么用?PHP IRequest::getFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Http\IRequest
的用法示例。
在下文中一共展示了IRequest::getFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleUpload
public function handleUpload()
{
$file = $this->httpRequest->getFile('Filedata');
if ($file->isOk()) {
$this->onUpload($file, $this->httpRequest->getPost());
} else {
$this->onError($file->getError());
}
$this->presenter->terminate();
}
示例2: handleSaveImage
/**
* it's not only handleGallerySaveImage now. We use it for save texy images too
*/
public function handleSaveImage()
{
if ($this->mainManager instanceof MagicManager && $this->mainManager->isGallery()) {
$folder = $this->mainManager->getGalleryFolder();
} else {
$this->error();
}
if ($folder == '') {
$folder = 'misc';
}
$file = $this->httpRequest->getFile('Filedata');
if ($file && $file->isOk() && $this->detailObject) {
// Save ...
$year = date('Y');
$month = date('m');
$namespace = "{$folder}/{$year}/{$month}";
$this->imageStorage->setNamespace($namespace);
$image = $this->imageStorage->save($file->getContents(), $file->getName());
$filename = pathinfo($image->getFile(), PATHINFO_BASENAME);
$size = $image->getSize();
// Prepare thumbnail
$this->imgPipe->setNamespace($namespace);
$this->imgPipe->request($filename, '100x100', 'exact');
// Save to database
$this->mainManager->addGalleryImage($filename, $namespace, $size->getWidth(), $size->getHeight(), $file->getContentType(), $this->detailObject->id);
$response = ['status' => '1', 'height' => $size->getHeight(), 'width' => $size->getWidth(), 'mime' => $file->getContentType()];
} else {
$response = ['status' => '0', 'error' => 'Error while uploading file', 'code' => 500];
}
$this->sendJson($response);
}
示例3: handleSaveImage
/**
* TODO: refactor use Aprila/Brick/ImageManager
*/
public function handleSaveImage()
{
$this->imageStorage->setNamespace("texy");
$onlinePath = 'texy/';
$response = array();
/** @var \Nette\Http\FileUpload $file */
if ($file = $this->httpRequest->getFile('file')) {
$filename = uniqid() . '.' . (pathinfo($file->name, PATHINFO_EXTENSION) ?: 'png');
$image = $this->imageStorage->save($file->getContents(), $filename);
$returnPath = pathinfo($image->file, PATHINFO_BASENAME);
if (FALSE) {
// $this->someManager->assignImageToObject($this->object->id, $returnPath, "texy");
}
$response['filename'] = $onlinePath . pathinfo($image->file, PATHINFO_BASENAME);
} else {
$response['error'] = 'Error while uploading file';
}
$this->sendJson($response);
}
示例4: handleSaveImage
public function handleSaveImage()
{
$file = $this->httpRequest->getFile('Filedata');
if ($file && $file->isOk()) {
$year = date('Y');
$month = date('m');
$namespace = "project/{$year}/{$month}";
$this->imageStorage->setNamespace($namespace);
$tempFilename = uniqid() . '.' . (pathinfo($file->getName(), PATHINFO_EXTENSION) ?: 'jpg');
$image = $this->imageStorage->save($file->getContents(), $tempFilename);
$size = $image->getSize();
$colorInfo = $this->getImageColorInfo($image->getFile());
$filename = pathinfo($image->getFile(), PATHINFO_BASENAME);
$this->addImage($filename, $namespace, $size->getWidth(), $size->getHeight(), $colorInfo, $file->getName(), $file->getContentType());
// Prepare thumbnail
$this->imgPipe->setNamespace($namespace);
$this->imgPipe->request($filename, '100x100', 'exact');
$response = ['status' => '1', 'height' => $size->getHeight(), 'width' => $size->getWidth(), 'mime' => $file->getContentType()];
} else {
$response = ['status' => '0', 'error' => 'Error while uploading file', 'code' => 500];
}
$this->sendJson($response);
}
示例5: getFile
/**
* @inheritdoc
*/
public function getFile($key)
{
return $this->current->getFile($key);
}