【发布时间】:2017-10-27 12:56:50
【问题描述】:
我有一个模型,其文件关系使用 OctoberCMS 的 system_files。
public $attachOne = [
'return_file' => ['System\Models\File', 'public' => false, 'delete' => true]
];
在 fields.yaml 我有表单
return_file:
label: Attach File
type: fileupload
mode: file
span: right
现在在我保存之前或之后,我想将图像从其目录移动到我插件中的自定义目录。 afterSave() 似乎没有检索文件路径来移动它。
但是在system_files中我看到MySQL workbench中其实已经上传了。
然而,当我在后端点击保存时,我得到“尝试获取非对象的属性”
这是 afterSave() 函数中的内容。
public function afterSave()
{
$custom_path = plugins_path() . '/acme/request/uploads/';
$file = $this->return_file->getPath();
$move_file = $file->move($custom_path);
}
是否可以在后端上传并在保存之前/之后移动文件?
【问题讨论】:
标签: php laravel octobercms