In OctoberCMS Multiple File Upload In Admin Section

时间:2016-08-31 17:29:41

标签: laravel octobercms

I am trying to upload multiple files in my custom component. First I have tried with mediafinder then fileupload but seems like nothing working.

I have google for admin section file upload.but there is no demo/example of multiple file upload in which user can upload multiple images and which is store uploaded file name in separate table.

Can anyone give me any demo/sample link of multiple file upload in admin section?

1 个答案:

答案 0 :(得分:1)

要将文件附加到模型,您需要在 attachOne attachMany 关系中使用 System \ Models \ File

public $attachOne = [
    'myfile' => 'System\Models\File'
];

public $attachMany = [
    'myfiles' => 'System\Models\File'
];

文档:https://octobercms.com/docs/database/attachments

通过编辑fields.yaml文件,将此myFile或myFiles添加到后端表单中。

myFile :
    label: myFile
    type: fileupload
    mode: file 

fileupload - 为图像或常规文件呈现文件上传器。字段名称必须使用attachOne或attachMany关系。

结果将是

enter image description here