增加附件上传功能

This commit is contained in:
Jack Freeman 2015-02-14 21:15:52 +08:00
parent 3cead0e3e7
commit 0a266bef02
1 changed files with 19 additions and 0 deletions

View File

@ -80,4 +80,23 @@ class Attachments extends AbstractEventManager implements ServiceManagerAwareInt
return $sql." DESC"; return $sql." DESC";
} }
public function upload($file)
{
$configService = $this->serviceManager->get('ConfigService');
$appConfig = $configService->get('application.ini');
$fileUploadService = $this->serviceManager->get('File/Upload');
$fileUploadService->attachDefaultListener();
$fileUploadService->setParams(['file_type' => 'file']);
$file_info = $fileUploadService($file,$appConfig['attachment_save_path'],"","",$fileUploadService::DATETIME_MODEL_Y);
if(isset($file_info['error']) && !empty($file_info['error']))
{
return array("error" => $file_info['error']);
}
return $file_info;
}
} }