I am trying to use an image uploader but it is generating error
Invalid parameter given. A valid $fileId[tmp_name] is expected.
I debugged and find out that the problem is in image uploader class of magento core.
please check my code.
my code in system.xml
<field id="image_upload1" translate="label" type="image" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Image Upload</label>
<backend_model>Magento\Config\Model\Config\Backend\Image</backend_model>
<upload_dir config="system/filesystem/media" scope_info="1">categoryBanner</upload_dir>
<base_url type="media" scope_info="1">categoryBanner</base_url>
<comment><![CDATA[Allowed file types: jpg, jpeg, gif, png, svg]]></comment>
</field>
my code of image.php
namespace Afg\Customsettings\Model\Config\Backend;
class Image extends \Magento\Config\Model\Config\Backend\Image
{
/**
* The tail part of directory path for uploading
*
*/
const UPLOAD_DIR = '/categoryBanner'; // Folder save image
/**
* Return path to directory for upload file
*
* @return string
* @throw \Magento\Framework\Exception\LocalizedException
*/
protected function _getUploadDir()
{
return $this->_mediaDirectory->getAbsolutePath($this->_appendScopeInfo(self::UPLOAD_DIR));
}
/**
* Makes a decision about whether to add info about the scope.
*
* @return boolean
*/
protected function _addWhetherScopeInfo()
{
return true;
}
/**
* Getter for allowed extensions of uploaded files.
*
* @return string[]
*/
protected function _getAllowedExtensions()
{
return ['jpg', 'jpeg', 'gif', 'png', 'svg'];
}
}