0

I want to obtain the file path inside my controller for the file uploaded in store configuration.In system.xml I have added the file upload section as

<section id="mageplaza_helloworld_section" translate="label" type="text" sortOrder="301" showInDefault="1" showInWebsite="1" showInStore="0">
    <label>Sales</label>
    <tab>sales</tab>
    <resource>Magento_Sales::config_sales</resource>
    <group id="custom_group" translate="label" type="text" sortOrder="6" showInDefault="1" showInWebsite="1" >
        <label>Security</label>
        <field id="custom_file_upload" translate="label" type="Magento\Config\Block\System\Config\Form\Field\File" sortOrder="6" showInDefault="1" showInWebsite="1" >
            <label>Upload custom file</label>
            <backend_model>Magento\Config\Model\Config\Backend\File</backend_model>
            <upload_dir config="system" scope_info="1">test</upload_dir>
        </field>
    </group>
</section> 

It's uploaded in my Magento root folder in path "magento_root/test/default".

Now let's say we upload the file abc.csv, I want this file path dynamically inside my controller.

0

You can get your system configuration value like this-

$this->scopeConfig->getValue('your_section/your_group/your_field', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.