Question

in magento 2.3.1 below code is work

<field id="file_upload" translate="label" type="Magento\Config\Block\System\Config\Form\Field\File" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
    <label>Upload File</label>
    <backend_model>Magento\Config\Model\Config\Backend\File</backend_model>
    <upload_dir config="system" scope_info="1">customUpload</upload_dir>
</field>

but in Magento 2.3.3 this not working it give error

Invalid parameter given. A valid $fileId[tmp_name] is expected.

enter image description here

Was it helpful?

Solution

i got the issue in file Magento\Framework\File\Uploader.php in which new method was added so i just comment that method, in function _setUploadFileId($fileId) found the

$this->validateFileId($fileId);  

change to

//$this->validateFileId($fileId);

it's work in my case in local server

OTHER TIPS

In my enviroment i found this issue in shared hosting. the validate function check the file uploaded by php in an array of dirs including the sys_get_temp_dir(), but that dir is different from $_FILES['input']['tmp_name'] base dir.

exampls:

sys_get_temp_dir() = /tmp

dir where php put temp file in my vhost: /home/mydomain/tmp

and so it fails during validation.

you should extend the Uploader.php with aplugin to add your local tmp path

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top