I am using file upload control at frontend using below code:
<div class="upload-wrapper" data-bind="scope: 'uploader'">
<!-- ko template: getTemplate() --><!-- /ko -->
</div>
<script type="text/x-magento-init">
{
".upload-wrapper": {
"Magento_Ui/js/core/app": {
"components": {
"uploader": {
"component": "Magento_Ui/js/form/element/file-uploader",
"template": "ui/form/element/uploader/uploader",
"previewTmpl": "MyCompany_Module/form/element/uploader/preview",
"dataScope": "custom.image",
"isLoading": true,
"maxFileSize": <?php echo $fileSize; ?>,
"isMultipleFiles": true,
"uploaderConfig": {
"url": "<?php echo $block->getUrl('router/image/upload', ['_current' => true, '_use_rewrite' => true]); ?>"
}
}
}
}
}
}
</script>
It was working fine with earlier Magento versions but creating issue with Magento 2.3.0. It shows attached error in console (Uncaught ReferenceError: Base64 is not defined)
I checked the same and found that in earlier versions, the processFile method in file-upoader.js (Magento_Ui/js/form/element/file-uploader) having below code:
processFile: function (file) {
file.previewType = this.getFilePreviewType(file);
this.observe.call(file, true, [
'previewWidth',
'previewHeight'
]);
return file;
}
but its updated as below in Magento 2.3:
processFile: function (file) {
file.previewType = this.getFilePreviewType(file);
console.log(file.name);
if (!file.id && file.name) {
file.id = Base64.mageEncode(file.name); //Base64 is globally defined
}
this.observe.call(file, true, [
'previewWidth',
'previewHeight'
]);
return file;
}
Please help me if someone has any idea on it.