如何在magento 2中添加自定义文件上传功能

问题描述:

我是通过Magento 2类别标签中的自定义模块创建的文件上传功能.我不知道如何将文件保存在数据库中.请问有人可以告诉我该怎么做吗?

Am created file upload functionality through custom module in Magento 2 category tab.i don't know how to save the file in database.please can any one tell me how to do that?

add use Magento\Framework\UrlInterface;
add use Magento\Framework\Filesystem;

...
$imageName = $this->uploadFileAndGetName('input_name', $this->fileSystem->getDirectoryWrite(DirectoryList::MEDIA)->getAbsolutePath($subdir_of_your_choice.'/image'));
$your_model->setImage($imageName);