Chrome version 83 encounters an issue preventing file uploads

I recently updated my Chrome browser to version 83 and encountered some issues with certain forms that utilize an "Ajax upload" component. Despite researching the problems associated with this new version (https://developers.google.com/web/updates/2020/05/nic83), I was unable to find any information related to forms, iframes, files, ajax, or posts.

I plan to create a sample on Fiddler to demonstrate the issue, but I'm reaching out to see if anyone else has encountered similar difficulties.

Interestingly, I have another form using a multifile, drag-and-drop uploader (dropzone.js) that is functioning properly. However, converting it may not be simple, so a quick solution would be preferable.

A basic example (as I don't have a sandbox for testing uploads): https://jsfiddle.net/drvespa/7ue8k94r/3/

  • In Chrome 83 (also tested in Canary version 85): no errors are thrown as the submission of the form is not caught by the AjaxUpload component. The callback function is being triggered before the submission completes, resulting in an empty response.
  • In Firefox: an error occurs because the AjaxUpload component is attempting to deserialize the 404 error from the dummy upload page.

The library can be found at :

/**
* Ajax upload
* Project page - http://valums.com/ajax-upload/
* Copyright (c) 2008 Andris Valums, http://valums.com
* Licensed under the MIT license (http://valums.com/mit-license/)
* Version 3.6 (26.06.2009)
*/

Answer №1

The issue arises from the library generating an <iframe>, setting its src attribute, and immediately listening for the load event of that iframe.

/**
* Creates iframe with unique name
*/
_createIframe: function () {
    // unique name
    // We cannot use getTime, because it sometimes return
    // same value in safari :(
    var id = getUID();

    // Remove ie6 "This page contains both secure and nonsecure items" prompt 

    var iframe = toElement('<iframe src="javascript:false;" name="' + id + '" />');
    iframe.id = id;
    iframe.style.display = 'none';
    d.body.appendChild(iframe);
    return iframe;
},

Next, in the submit method

            var iframe = this._createIframe();

            // some synchronous operations

            addEvent(iframe, 'load', function (e) { // ...

Due to the presence of the src attribute in the iframe, Chrome initiates its loading process. However, since the src is a fake URL, this operation resolves synchronously, causing the load event to be scheduled for the following event-loop iteration.

const frame = document.createElement('iframe');
frame.src = 'javascript:return false';
document.body.append(frame);
frame.addEventListener('load', (evt) => console.log('loaded', frame.src) );

setTimeout( () => frame.src = "about:blank", 0 );

// Results in Chrome:
// loaded javascript:return false
// loaded about:blank

// Results in Firefox:
// loaded about:blank

Hence, the only load event caught by this library pertains to the initial load event of an empty document, rather than the actual request's load event.

To resolve this issue, simply remove the src="javascript:false;" from the library code: https://jsfiddle.net/9phxmqjw/

Answer №2

I have successfully resolved an issue by setting the srcdoc attribute of the iframe to a specific url within the AjaxUpload component.

To accomplish this, I used the following code:

iframe.setAttribute('srcdoc', this._settings.action);

This simple solution effectively fixed the problem I was facing.

The function responsible for creating the iframe can be found in the AjaxUpload.js file:

_createIframe: function(){
    var id = getUID();            

    var iframe = toElement('<iframe src="javascript:false;" name="' + id + '" />');        
    iframe.setAttribute('id', id);
    iframe.setAttribute('srcdoc', this._settings.action);

    iframe.style.display = 'none';
    document.body.appendChild(iframe);

    return iframe;
}

Answer №3

Thanks to this solution, our team was able to successfully fix the issue with uploading attachments on Atmail in Chrome 83.

To implement this fix, we inserted the setAttribute line into the AjaxUpload.js file within the '_createIframe' function. Placing it right below the setAttribute('id', id) call proved to be effective :)

Answer №4

Our team used an outdated plugin in the past:

http://jquery.malsup.com/form/#options-object

If you were supporting ie8 within the last decade, there's a specific option you may have encountered...

{
    url: '/branded/image_upload',
    type: 'POST',
    iframe: false
}

We even had to resort to using a

<textarea></textarea>
hack in the response.

This code has been passed through numerous iterations over time!

Answer №5

Appreciate your help! To fix image and document upload in Opencart 1.5 after the Chrome Update, you can add this code snippet:

iframe.setAttribute('srcdoc', this._settings.action);

You can find where to insert this code in \admin\view\javascript\jquery\ajaxupload.js file.

var iframe = toElement('<iframe src="javascript:false;" name="' + id + '" />');
            // Added src="javascript:false;
            // This prevents the IE6 prompt "This page contains both secure and nonsecure items"
            // It won't cause any issues.
            iframe.setAttribute('id', id);
               iframe.setAttribute('srcdoc', this._settings.action);
               iframe.style.display = 'none';
               document.body.appendChild(iframe);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to display JSON containing nested objects in AngularJS using the ng-repeat directive

Hey everyone, I have this JSON external file that I need help with: { "success":true, "errors":[ ], "objects":[ { "cod":"8211300", "descricao":"Serviços advocatícios" }, // more objects here... ] } In ...

Halting the execution of a jQuery function when a condition is true

Currently in the process of building a website for my new brand, I am faced with a challenge while working with jQuery for the first time. Specifically, I am encountering issues related to the state of a specific div. The code contains if statements that ...

Conceal a div using jQuery when clicked

I am facing an issue with my script where I need to make a div close only after clicking on a link, instead of anywhere outside the div. http://jsfiddle.net/N4pbP/ $(function() { $('#hidden').hide().click(function(e) { e.stopPropagation() ...

What is causing the error "Expected an assignment or function call and instead saw an expression" to occur in this situation?

I am encountering an error that says "Expected an assignment or function call and instead saw an expression" at the second useEffect. The socket port is being detected correctly, but I suspect my usage of socket.on may be incorrect. The socket server initi ...

The ajax call made a double request, with the first one returning a status of 400 and the second one

Here is my code for creating a record: def create @categorization = Categorization.new(categorization_params) @categorization.save respond_to do |format| format.json { render json: {categorization: @categorization.to_json}, success: 20 ...

Containers for Comparing Images are Unable to Flexibly Wrap

Check out my codepen project here: https://codepen.io/Bryandbronstein/pen/NLVQjB I've encountered a peculiar issue while experimenting with CSS and Javascript. I came across an image comparison slider on the W3C website that worked flawlessly as a si ...

Retrieve data from the database and showcase it in the input fields

There are 7 checkboxes for each day of the week (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday) with start and end time tags for each. Take a look at the design picture below. Within the database, there are multiple entries where the firs ...

Try making a series of interconnected fetch requests in Redux Toolkit that rely on the completion of the previous fetch

I am still learning the ropes of Redux and I'm feeling a bit lost. My goal is to make two API calls - one to retrieve an account Id and a category Id, and another to get a list of transactions based on those IDs. The createApi function in my code lo ...

Codeception's Webdriver appears to be malfunctioning as the $I->fillField command is not functioning properly, despite the field

As a newcomer to Codeception, I am encountering an issue with the following piece of code: $I->click("a.slideout-toggle-add-employee"); $I->wait(2); $I->seeElement(Locator::find('input', ['placeholder' => 'Vor ...

Using React Native to display an SVG path inside an SVG viewbox

I'm working on incorporating a barcode scanner viewfinder with an SVG icon to enhance its appearance. However, I am facing difficulty in making the path element within the SVG take up the full width and height of the SVG. In my React Native project, I ...

Froala Editor: Innovative external toolbar that pops up when the button is clicked

In our project, we are implementing the latest version of Froala and aim to configure it so that the toolbar is activated by a separate external button, similar to Gmail where the editor initially does not display a toolbar. I attempted to modify the &apo ...

How to add values at a particular index within an array using JavaScript

First, I start by creating an array with a specific size. $("#bntSize").one('click', function(e){ var memory = $("#memory").val(); console.log(memory) html = ""; for(var i = 0; i < memory ; i++){ ...

Is it possible to apply a styling to a table data cell based on the table header relationship

Let's say I have a table header with content like this... <th> <div class="text-left field-sorting " rel="local_inventory"> Local inventory </div> </th> <th> <div class="text-left field-sorting " rel="something el ...

Ways to execute function when state changes, excluding initial loading

I need to trigger a function when the state's data changes, excluding the initial load. Below is my code snippet: const Page = (props) => { const { data } = props; const arrowDirection = (item) => { if (item.arrow === 1) { return ...

React allows for items to be exchanged between two lists

I am currently working on a functionality that involves swapping items between two arrays. The user interacts with two lists in the UI by selecting items from the first list, which should then be removed from there and added to the second list where the se ...

How can I convert an HTML/CSS form into a PDF without altering its CSS design?

On my form, there are specific fields that users need to fill out. I'm looking for a way to automatically generate a PDF when these fields are submitted. Can anyone provide assistance with this? Currently, I've been redirecting the form data to ...

Creating a file structure for JavaScript files in a Vue CLI project

When structuring my Vue CLI project, I'm struggling to find clear documentation on best practices. Currently, I have 10 modules each with an associated JS file. My approach so far involves organizing all the pages in my router.js within a views direc ...

Is there a way to invoke a function within an Angular Service from within the same service itself?

Below is the code snippet I am working with: angular.module('admin') .factory('gridService', ['$resource', 'gridSelectService', 'localStorageService', function ($resource, gridSelectService, ...

What is the best way to ensure that an iframe adjusts its height to fit the content within a tabbed container?

Is there a way to dynamically set the height of an iframe to match the content inside it when clicking on a tabbed plane? Initially, I used a fixed height of 1000px. How can this be achieved? <div class="container-fluid text-center"> <div ...

How to retrieve an unknown JSON key in Vue.js when using v-for loop?

I have developed a code analysis tool and I am looking to display my JSON data in a Vue table. The challenge is that I need the JSON key, which represents the package/file name of the directory whose data I want to showcase. Below is an excerpt of the JSO ...