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">
    <group id="custom_group" translate="label" type="text" sortOrder="6" showInDefault="1" showInWebsite="1" >
        <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>
            <upload_dir config="system" scope_info="1">test</upload_dir>

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.


You can get your system configuration value like this-

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

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.