1

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

8
  • If is not Magento 2.3.3 issue. Because I've used same code in my M2.3.3 and it is working fine. Can you please use this configuration anywhere else and check ? Commented Oct 16, 2019 at 18:00
  • Hi @KishanSavaliya i used this configuration in my custom module where i getting this error also i test this code in local Commented Oct 17, 2019 at 4:03
  • can you please check you exception.log or system.log in var/log directory ? From where you're getting this issue ? Is that your any custom module or default magento file ? Commented Oct 17, 2019 at 4:08
  • no i have install new magento 2.3.3 and also magento core functionality in configuration -> Sales -> Invoice and Packing Slip Design -> Logo for PDF Print-outs (200x50) not working , in live server it's work but not in local Commented Oct 17, 2019 at 5:19
  • You can check this image <drive.google.com/file/d/1WL17yXTjJDHOZk8IVaEhwCelyIpSonUu/…> I just updated that image here which you've mentioned here. And that is working with default Magento 2.3.3 version. Commented Oct 17, 2019 at 7:45

2 Answers 2

2

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

3
  • by simply removing the validation, you don't solve the problem. You just ignore it. And: It's never a good idea to change a file in vendor/* as it will be rewritten on every deployment (composer install/update).
    – Ali Raza
    Commented Sep 14, 2020 at 11:41
  • 1
    yes @AliRaza i know that change in vendor/* is never recommended but it's only for in local (xampp) server. in liver server works fine without any changes. Commented Sep 14, 2020 at 12:27
  • 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 Commented Mar 23, 2021 at 13:05
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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