protected function saveUploadedFile() { $file = new Gpf_Db_File(); $file->set('filename', $this->name); $file->set('filesize', $this->size); $file->set('filetype', $this->type); $file->save(); $dir = new Gpf_Io_File($this->getZipFolderUrl().$file->getFileId().'/'); if ($dir->isExists()) { $dir->delete(); } $dir->mkdir(); $tmpZip = new Gpf_Io_File($this->getZipFolderUrl().$file->getFileId().'/'.$file->getFileId().".zip"); $dir->copy(new Gpf_Io_File($this->tmpName),$tmpZip); $archive = new PclZip($this->getZipFolderUrl().$file->getFileId().'/'.$file->getFileId().".zip"); $err = $archive->extract($this->getZipFolderUrl().$file->getFileId().'/'); if ($err <= 0) { throw new Gpf_Exception("code: ".$err); } $tmpZip->delete(); return $file; }
/** * Download file from server * * @param Gpf_Rpc_Params $params * @service db_file read */ public function download(Gpf_Rpc_Params $params) { try { $form = new Gpf_Rpc_Form($params); if (!strlen($form->getFieldValue('fileid'))) { throw new Gpf_Exception("No fileid specified"); } $this->file = new Gpf_Db_File(); $this->file->set('fileid', $form->getFieldValue("fileid")); $this->file->load(); try { if ($form->getFieldValue('attachment') == Gpf::YES) { $this->isAttachment = true; } else { $this->isAttachment = false; } } catch (Exception $e) { $this->isAttachment = false; } } catch (Gpf_DbEngine_NoRow $e) { throw new Exception($this->_("File does not exist")); } catch (Exception $e) { throw new Exception($e->getMessage()); } return $this; }
/** * * @return Gpf_Db_File */ protected function saveUploadedFile() { $file = new Gpf_Db_File(); $file->set('filename', $this->name); $file->set('filesize', $this->size); $file->set('filetype', $this->type); $file->save(); $this->uploadContent($this->tmpName, $file); return $file; }