/**
  * 删除附件
  *
  * @param string $path 附件地址
  */
 public function delete($path, $ifthumb = 0)
 {
     Pw::deleteFile(ATTACH_PATH . $path);
     if ($ifthumb) {
         $ifthumb & 1 && Pw::deleteFile(ATTACH_PATH . 'thumb/' . $path);
         $ifthumb & 2 && Pw::deleteFile(ATTACH_PATH . 'thumb/mini/' . $path);
     }
     return true;
 }
 /**
  * 存储附件,如果是远程存储,记得删除本地文件
  *
  * @param string $source 本地源文件地址
  * @param string $filePath 存储相对位置
  * @return bool
  */
 public function save($source, &$filePath)
 {
     $data = WindFile::read($source);
     $stuff = WindFile::getSuffix($source);
     $result = $this->_getCdn()->write($data, $stuff);
     if ($result) {
         Pw::deleteFile($source);
         $filePath = $result;
         return true;
     } else {
         return false;
     }
 }
Exemple #3
0
 /**
  * 附件上传失败,回调函数
  *
  * @param PwUploadFile $file
  * @return void
  */
 public function fileError(PwUploadFile $file)
 {
     Pw::deleteFile($file->source);
 }
 /**
  * 存储附件,如果是远程存储,记得删除本地文件
  *
  * @param string $source 本地源文件地址
  * @param string $filePath 存储相对位置
  * @return bool
  */
 public function save($source, $filePath)
 {
     $this->_getFtp()->upload($source, $filePath);
     Pw::deleteFile($source);
     return true;
 }