如何在magento 2中添加自定义文件上传功能 [英] How to add Custom file upload function in magento 2

查看:117
本文介绍了如何在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);

这篇关于如何在magento 2中添加自定义文件上传功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆