当前位置: 首页>>代码示例>>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;未经允许,请勿转载。