本文整理汇总了PHP中HTTPRequest::fileExists方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTPRequest::fileExists方法的具体用法?PHP HTTPRequest::fileExists怎么用?PHP HTTPRequest::fileExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPRequest
的用法示例。
在下文中一共展示了HTTPRequest::fileExists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeAvatar
public function executeAvatar(HTTPRequest $request)
{
ini_set("memory_limit", '256M');
$this->page->smarty()->assign('avatar', $this->_profilePro->getAvatar());
if ($request->fileExists('avatar')) {
$avatar = $request->fileData('avatar');
if ($avatar['error'] == 0) {
$simpleImage = new SimpleImage();
$simpleImage->load($avatar['tmp_name']);
if (!is_null($simpleImage->image_type)) {
$height = $simpleImage->getHeight();
$width = $simpleImage->getWidth();
if ($height > $width) {
$simpleImage->resizeToHeight(150);
} else {
$simpleImage->resizeToWidth(150);
}
$filename = time() . '.jpg';
$simpleImage->save($_SERVER['DOCUMENT_ROOT'] . $this->_userDir . $filename);
if ($this->_profilePro->getAvatar() != ProfilePro::AVATAR_DEFAULT_PRO) {
unlink($_SERVER['DOCUMENT_ROOT'] . $this->_profilePro->getAvatar());
}
$this->_profilePro->setAvatar($this->_userDir . $filename);
$this->_profileProManager->save($this->_profilePro);
$this->app->user()->setFlash('avatar-updated');
} else {
$this->app->user()->setFlash('avatar-error');
}
} else {
$this->app->user()->setFlash('avatar-error');
}
$this->app->httpResponse()->redirect('/profile-pro');
}
}
示例2: parsePhoto
private function parsePhoto(HTTPRequest $request, AnnouncementPro $announce)
{
ini_set("memory_limit", '512M');
if ($request->fileExists('photo-main')) {
$photoMain = $request->fileData('photo-main');
$this->savePhoto($announce, 'PhotoMain', $photoMain);
}
if ($request->fileExists('photo-option-1')) {
$photoOption1 = $request->fileData('photo-option-1');
$this->savePhoto($announce, 'PhotoOption1', $photoOption1);
}
if ($request->fileExists('photo-option-2')) {
$photoOption2 = $request->fileData('photo-option-2');
$this->savePhoto($announce, 'PhotoOption2', $photoOption2);
}
}
示例3: parsePhoto
private function parsePhoto(HTTPRequest $request, Announcement $announce)
{
ini_set("memory_limit", '512M');
if ($request->postExists('delete-photo-main')) {
unlink(MediaImage::getAnnounceDirectory($announce) . '/' . $announce->getPhotoMain());
unlink(MediaImage::getAnnounceDirectory($announce) . '/' . Announcement::THUMBNAILS_PREFIX . $announce->getPhotoMain());
$announce->setPhotoMain('');
}
if ($request->postExists('delete-photo-option-1')) {
unlink(MediaImage::getAnnounceDirectory($announce) . '/' . $announce->getPhotoOption1());
unlink(MediaImage::getAnnounceDirectory($announce) . '/' . Announcement::THUMBNAILS_PREFIX . $announce->getPhotoOption1());
$announce->setPhotoOption1('');
}
if ($request->postExists('delete-photo-option-2')) {
unlink(MediaImage::getAnnounceDirectory($announce) . '/' . $announce->getPhotoOption2());
unlink(MediaImage::getAnnounceDirectory($announce) . '/' . Announcement::THUMBNAILS_PREFIX . $announce->getPhotoOption2());
$announce->setPhotoOption2('');
}
if ($request->fileExists('photo-main')) {
$photoMain = $request->fileData('photo-main');
$this->savePhoto($announce, 'PhotoMain', $photoMain);
}
if ($request->fileExists('photo-option-1')) {
$photoOption1 = $request->fileData('photo-option-1');
$this->savePhoto($announce, 'PhotoOption1', $photoOption1);
}
if ($request->fileExists('photo-option-2')) {
$photoOption2 = $request->fileData('photo-option-2');
$this->savePhoto($announce, 'PhotoOption2', $photoOption2);
}
}