如何在Magento 2中添加自定义文件上传功能 [英] How to add a custom file upload function in Magento 2
本文介绍了如何在Magento 2中添加自定义文件上传功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过Magento 2类别选项卡中的一个定制模块创建了一些文件上传功能。我不知道如何将文件保存到数据库中。我该怎么做呢?
推荐答案
add use MagentoFrameworkUrlInterface;
add use MagentoFrameworkFilesystem;
...
$imageName = $this->uploadFileAndGetName('input_name', $this->fileSystem->getDirectoryWrite(DirectoryList::MEDIA)->getAbsolutePath($subdir_of_your_choice.'/image'));
$your_model->setImage($imageName);
这篇关于如何在Magento 2中添加自定义文件上传功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文