Smit Shah
Smit Shah

Reputation: 344

In OctoberCMS Multiple File Upload In Admin Section

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?

Upvotes: 2

Views: 1000

Answers (1)

To attach file to a model you need to use System\Models\File in a attachOne or attachMany relation

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

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

documentation : https://octobercms.com/docs/database/attachments

Add this myFile or myFiles into you backend form by editing the fields.yaml file.

myFile :
    label: myFile
    type: fileupload
    mode: file 

fileupload - renders a file uploader for images or regular files. The field name must use an attachOne or attachMany relation.

The result would be

enter image description here

Upvotes: 1

Related Questions