3

I have a Magento 2.1.9 installed. When I try to upload an image for a category from backend in the IE11 browser it shows a script error

SCRIPT438: Object doesn't support property or method 'set'

and failed to upload the image. The script error has occurred in the file.

Magento_Ui/js/form/element/file-uploader.js

in line number 307 ie,

postData.data.set('param_name', this.paramName);

We have checked the same scenario in a lower Magento version Magento 2.1.2, but here this is working fine and no error occurs. So we have compared the js files and find out the difference in both versions. In Magento 2.1.9 the "onBeforeFileUpload" function is like as follows

onBeforeFileUpload: function (e, data) {
            var file     = data.files[0],
                allowed  = this.isFileAllowed(file),
                target   = $(e.target);

            if (allowed.passed) {
                target.on('fileuploadsend', function (event, postData) {
                    postData.data.set('param_name', this.paramName);
                    $(event.currentTarget).off('fileuploadsend');
                }.bind(data));

                target.fileupload('process', data).done(function () {
                    data.submit();
                });
            } else {
                this.notifyError(allowed.message);
            }
        },

But in Magento 2.1.2 it is like

onBeforeFileUpload: function (e, data) {
    var file = data.files[0],
    allowed = this.isFileAllowed(file);
    if (allowed.passed) {
        $(e.target).fileupload('process', data).done(function () {
            data.submit();
        });
    } else {
        this.notifyError(allowed.message);
    }
},

Note : This issue is only in IE browser. I have tested this in IE11

1

The issue you have specified is of magento's issue (in magento 2.1.9).

Thers is a solution for this , since the console says that "SCRIPT438: Object doesn't support property or method 'set' " so you can use "append" method instead of 'set' method. so the final code be like

onBeforeFileUpload: function (e, data) {
        var file     = data.files[0],
            allowed  = this.isFileAllowed(file),
            target   = $(e.target);

        if (allowed.passed) {
            target.on('fileuploadsend', function (event, postData) {
                postData.data.append('param_name', this.paramName);
                $(event.currentTarget).off('fileuploadsend');
            }.bind(data));

            target.fileupload('process', data).done(function () {
                data.submit();
            });
        } else {
            this.notifyError(allowed.message);
        }
    },

Its works fine for me . Before changing don't forget to override the core file.

Thank you

  • -@Munna - thanks bro for the fix. You saved my time. – amesh Apr 6 '18 at 11:00
  • @munna- i am getting this error, Object doesn't support property or method 'from' – jafar pinjar Nov 26 '18 at 12:54
  • @jafarpinjar please identify from where the error is getting? – munnadileep Nov 27 '18 at 13:09
  • @munnadileep, yes i have fixed it, its a javascript issue – jafar pinjar Nov 27 '18 at 13:23

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.