增加附件上传功能
This commit is contained in:
parent
3cead0e3e7
commit
0a266bef02
|
@ -80,4 +80,23 @@ class Attachments extends AbstractEventManager implements ServiceManagerAwareInt
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue