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


PHP HTTPRequest::fileData方法代碼示例

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


在下文中一共展示了HTTPRequest::fileData方法的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');
     }
 }
開發者ID:Tipkin-Commons,項目名稱:tipkin,代碼行數:34,代碼來源:ProfileproController.class.php

示例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);
     }
 }
開發者ID:Tipkin-Commons,項目名稱:tipkin,代碼行數:16,代碼來源:AnnouncementsproController.class.php

示例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);
     }
 }
開發者ID:Tipkin-Commons,項目名稱:tipkin,代碼行數:31,代碼來源:AnnouncementsController.class.php


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