Magento – Magento 2: How to add a browse button to upload file in admin section

adminfile uploadmagento2module

Working on Magento 2 custom module implementation and want to add a browse button to upload a file in admin form.

I have gone through the

Magento2 : Admin module Image upload code to display form

but it's not working for me.

Any help is appreciated.

Thanks!

enter image description here

Best Answer

if ($id) {
                $model->load($id);
            }
After This Add the below code

 if(is_array( $data['image'])){
                $data['image']=implode(" ",$data['image']);

                $model->setData($data);

            }
            else {
                $model->setData($data);
            }

Do this thing it will solve ur issue