Пример #1
0
 public function putByFiletype($filetype, $source)
 {
     if (!$this->get_fid()) {
         return NULL;
     }
     if (trim($filetype) == '') {
         return NULL;
     }
     if ($this->oid > 0) {
         return NULL;
     }
     //此文件不是原始上传文件
     $uploader = new Uploader();
     $uploader->process($source);
     $uploader->ctrl_type = $this->ctrl_type;
     $uploader->filename = $this->getFilename() . '.' . $filetype;
     $uploader->oid = $this->fid;
     $uploader->thumb_id = $this->thumb_id;
     $basedir = '/home';
     $basedirModel = new FileDirectory($this->uid);
     if (!$basedirModel->findOne($basedir)) {
         Core::header('x-apiperf-nondir:' . json_encode($basedir));
         Core::fault(500);
     }
     if ($newFileEntry = $basedirModel->makeFile($uploader)) {
         return $newFileEntry;
     }
     return FALSE;
 }
Пример #2
0
 public function makeDir($dirname)
 {
     if ($dir_name = $this->getFilename($dirname)) {
         $dirpath = $this->path . '/' . $dir_name;
         $dirModel = new FileDirectory();
         if ($dirModel->findOne($dirpath)) {
             return $dirModel;
         }
         if ($dirModel->create($dirpath, $this->get_fid())) {
             return $dirModel;
         }
     }
     return FALSE;
 }