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


PHP UploadFile::model方法代碼示例

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


在下文中一共展示了UploadFile::model方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionPersistentNotify

 public function actionPersistentNotify()
 {
     $result = json_decode(file_get_contents("php://input"));
     foreach ($result->items as $item) {
         $key = substr($item->key, 0, strlen($item->key) - 5);
         $uploadFile = UploadFile::model()->findByAttributes(array('path' => $key));
         if ($uploadFile) {
             if ($item->code == 0) {
                 $uploadFile->convertStatus = "success";
             } else {
                 if ($item->code == 1) {
                     $uploadFile->convertStatus = "waiting";
                 } else {
                     if ($item->code == 2) {
                         $uploadFile->convertStatus = "doing";
                     } else {
                         if ($item->code == 3 || $item->code == 4) {
                             $uploadFile->convertStatus = "error";
                             error_log(print_r($item, true));
                         }
                     }
                 }
             }
             $uploadFile->convertKey = "{$key}.m3u8";
             //	error_log(print_r($uploadFile,true));
             if ($uploadFile->save()) {
                 //		error_log('s');
             } else {
                 error_log('fail in persistentNotify');
             }
         }
     }
 }
開發者ID:stan5621,項目名稱:jp_edu_online,代碼行數:33,代碼來源:CloudController.php

示例2: getFile

 public function getFile()
 {
     $criteria = new CDbCriteria();
     $criteria->join = "left join ew_lesson l on  l.mediaId=t.id";
     $criteria->condition = "l.mediaType='video' and l.id=" . intval($this->id);
     $file = UploadFile::model()->find($criteria);
     return $file;
 }
開發者ID:stan5621,項目名稱:jp_edu_online,代碼行數:8,代碼來源:Lesson.php

示例3: actionConvert

 public function actionConvert()
 {
     $files = UploadFile::model()->findAllByAttributes(array('storage' => 'cloud'));
     $cloud = CloudService::getInstance();
     foreach ($files as $file) {
         if (!$file->convertKey) {
             echo $file->path;
             echo $cloud->convert($file->path);
             echo "\n";
         }
     }
 }
開發者ID:stan5621,項目名稱:eduwind,代碼行數:12,代碼來源:ChapterController.php

示例4: getOldFile

 public function getOldFile()
 {
     if ($this->_oldMediaType == "video" && $this->_oldMediaId) {
         return UploadFile::model()->findByPk($this->_oldMediaId);
     }
 }
開發者ID:stan5621,項目名稱:eduwind,代碼行數:6,代碼來源:Lesson.php

示例5: saveAttachment

 /**
  * 保存一個附件
  * @param unknown_type $attribute
  * @throws CException
  */
 public function saveAttachment($attribute)
 {
     $file = AttachmentUploadedFile::getInstance($this->Owner, $attribute);
     if (!is_null($file)) {
         //			if(!$this->Owner->isNewRecord){
         //delete previous attachment
         //			if(file_exists($this->Owner->{$attribute})){
         $this->Owner->refresh();
         $uploadFile = UploadFile::model()->findByPk($this->Owner->{$attribute});
         if ($uploadFile) {
             $uploadFile->delete();
         }
         $this->Owner->isNewRecord = false;
         //unlink($this->Owner->{$attribute});
         //		}
         //			}else{
         //				$this->Owner->isNewRecord = false;
         //			}
         preg_match('/\\.(.*)$/', $file->name, $matches);
         $this->file_extension = end($matches);
         //檢查後綴名是否符合
         if (!empty($this->items[$attribute]['exts']) && !in_array($this->file_extension, $this->items[$attribute]['exts'])) {
             return false;
         }
         $this->filename = $file->name;
         $path = $this->getParsedPath($attribute);
         preg_match('|^(.*[\\\\/])|', $path, $match);
         $folder = end($match);
         if (!is_dir($folder)) {
             mkdir($folder, 0777, true);
         }
         $file->saveAs($path, false);
         $file_type = filetype($path);
         $uploadFile = new UploadFile();
         $uploadFile->userId = Yii::app()->user->id;
         $uploadFile->addTime = time();
         $uploadFile->name = $file->name;
         //$uploadFile->mime  = mime_content_type($path);
         $uploadFile->mime = CFileHelper::getMimeType($path) ? CFileHelper::getMimeType($path) : "";
         $uploadFile->type = $this->file_extension;
         $uploadFile->size = filesize($path);
         $uploadFile->path = $path;
         $uploadFile->save();
         $this->Owner->saveAttributes(array($attribute => $uploadFile->id));
     }
     return true;
 }
開發者ID:stan5621,項目名稱:jp_edu_online,代碼行數:52,代碼來源:UploadFileBehavior.php


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