php - 如何从 october cms 中的插件形式上传图像?
问题描述
我正在尝试将 fileUpload 添加到我的多站点插件中,同时添加一个新域,我想上传该网站的国旗。我尝试了一些东西,但是在尝试显示 crating 新域表单时出现了这个错误。错误:
Model'Keios\Multisite\Models\Setting' does not contain a definition for 'image' october cms
我创建了另一个插件亲属,我添加了我想在多站点插件中创建的更改
MultisiteModel::extend(function (MultisiteModel $model){
$model->attachOne=[
'flag' => 'System\Models\File'
];
});
解决方案
在插件的模型文件中添加:
image 应该是你的领域的名字!
public $attachOne = [
'image' => 'System\Models\File'
];
然后您可以将其称为 $model->image 以获取更多信息,请查看文档https://octobercms.com/docs/database/attachments#file-attachments