How To Upload Image In Magento2 , Custom File Uploads in Magento 2 (100% work)

I don’t know why 2 top topics in google don’t work because silly things.

this link :

how to upload image in magento2

It doesn’t work because

$path = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA)
     
    ->getAbsolutePath('images/'); 
_filesystem used without declaring in contruct method.
In this link https://www.smartiehastheanswer.co.uk/magento2/custom-file-uploads-in-magento2.html
It doesn’t work because don’t have instruction about create form with enctype
$form = $this->_formFactory->create(
[‘data’ => [‘id’ => ‘edit_form’, ‘action’ => $this->getData(‘action’), ‘method’ => ‘post’ ,’enctype’=>’multipart/form-data’]]
);
I will prepare time upload extension have upload function only soon

Leave a Reply

Your email address will not be published. Required fields are marked *