예제 #1
0
 /**
  * [uploadFile Upload file.]
  * @param  [Object] $model    [active form model]
  * @param  [String] $attr     [attribute]
  * @param  string $rootPath [description]
  * @return [Object | null]           [description]
  */
 public function uploadFile(Resource $model, $attr, $rootPath = '')
 {
     $fileObj = UploadedFile::getInstance($model, $attr);
     $model->name = $fileObj->baseName;
     $model->size = Common::transByte($fileObj->size);
     $model->extension = $fileObj->extension;
     $model->status = $this->setStatus($fileObj->extension);
     $model->resource_type = $this->setResType($fileObj->extension, $model->course_id);
     return $this->upload($model, $attr, $rootPath);
     // var_dump($model);die;
     // $dir = $this->setDir($fileObj->extension);
     // $relaPath = '/' . $dir . '/' . $fileObj->baseName . '.'. time(). '.' . $fileObj->extension;
     // $model->$attr = $relaPath;
     // if ($fileObj && $model->validate()) {
     //     $fileObj->saveAs($rootPath . $relaPath);
     //     return $model;
     // }
 }