Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Upload cancelled in Chrome 83.0.4103.61 #185

Open
chocolata opened this issue May 26, 2020 · 10 comments
Open

Upload cancelled in Chrome 83.0.4103.61 #185

chocolata opened this issue May 26, 2020 · 10 comments

Comments

@chocolata
Copy link

chocolata commented May 26, 2020

After updating Chrome to the most recent version (83.0.4103.61 in my case), the upload function of KCfinder seems to be broken. You can select a file, but immediately after the upload starts, it is cancelled. See enclosed screenshot. Does anyone have a solution for this? Should we hope that it is a bug in Chrome or is this wishful thinking? Thanks in advance.
Inkedunnamed_LI

Strangely, dragging and dropping files to upload seems to be unaffected...

@lowbatteries
Copy link

I'm having this issue as well in Chrome 83 (not present in Chrome 81), and am trying to find a solution. The bug also happens in the beta Chrome 85, so I don't think it will go away with a Chrome update.

@chocolata
Copy link
Author

Thanks for your response. Keep us posted if you find anything. I'm looking for a solution aswel. In the JavaScript-files I regularly encounter async: false; regarding AJAX requests. Could this have anything to do with it?

I've been looking here, at the moment in vain:
https://developers.google.com/web/updates/2020/04/chrome-83-deps-rems

@lowbatteries
Copy link

lowbatteries commented May 26, 2020

I think I've found it. js/browser/toolbar.js, the $('#uploadResponse').load function is being fired immediately when it is created, short-circuiting the upload process.

Removing the src attributes from this iframe fixes it:
$('<iframe id="uploadResponse" name="uploadResponse" src="javascript:;"></iframe>').

@chocolata
Copy link
Author

Hi @lowbatteries thank you so much for this. I can confirm that this also fixes it for me!
You wouldn't be up to forking this library and maintaining it, would you?

@sergey-dryabzhinsky
Copy link

You can try this fix:

--- toolbar.js.old	2014-03-12 02:33:27.000000000 +0400
+++ toolbar.js	2020-05-27 15:28:31.951677064 +0300
@@ -142,31 +142,39 @@
         return;
     }
     form.elements[1].value = browser.dir;
-    $('<iframe id="uploadResponse" name="uploadResponse" src="javascript:;"></iframe>').prependTo(document.body);
     $('#loading').html(this.label("Uploading file..."));
     $('#loading').css('display', 'inline');
-    form.submit();
-    $('#uploadResponse').load(function() {
-        var response = $(this).contents().find('body').html();
-        $('#loading').css('display', 'none');
-        response = response.split("\n");
-        var selected = [], errors = [];
-        $.each(response, function(i, row) {
-            if (row.substr(0, 1) == '/')
-                selected[selected.length] = row.substr(1, row.length - 1)
-            else
-                errors[errors.length] = row;
-        });
-        if (errors.length)
-            browser.alert(errors.join("\n"));
-        if (!selected.length)
-            selected = null
-        browser.refresh(selected);
-        $('#upload').detach();
-        setTimeout(function() {
-            $('#uploadResponse').detach();
-        }, 1);
-        browser.initUploadButton();
+/* Fix new Chrome */
+    var post = new FormData(form);
+    $.ajax({
+        url: $(form).attr('action'),
+        type: 'POST',
+        data: post,
+        processData: false,
+        contentType: false,
+        cache: false,
+        success: function(data) {
+            $('#loading').css('display', 'none');
+
+            response = data.split("\n");
+            var selected = [], errors = [];
+            $.each(response, function(i, row) {
+                if (row.substr(0, 1) == '/')
+                    selected[selected.length] = row.substr(1, row.length - 1)
+                else
+                    errors[errors.length] = row;
+            });
+            if (errors.length)
+                browser.alert(errors.join("\n"));
+            if (!selected.length)
+                selected = null
+            browser.refresh(selected);
+            $('#upload').detach();
+        },
+        error: function(e) {
+            $('#loading').css('display', 'none');
+            browser.alert("Can't upload file!\nSever error!");
+        }
     });
 };

@noorfathima5690
Copy link

Thank you, Removing src attribute from the iframe works, I changed in js/toolbar.js and cache/base.js

@chocolata chocolata reopened this May 28, 2020
@chocolata
Copy link
Author

Is there any way where we can get these fixes pushed into the repo?

@lois333
Copy link

lois333 commented May 29, 2020

Thank you, works for me !

@ufukucar
Copy link

I think I've found it. js/browser/toolbar.js, the $('#uploadResponse').load function is being fired immediately when it is created, short-circuiting the upload process.

Removing the src attributes from this iframe fixes it:
$('<iframe id="uploadResponse" name="uploadResponse" src="javascript:;"></iframe>').

Thanks. That solved my problem

@finnef
Copy link

finnef commented Jun 3, 2020

FYI jquery upload was broken by the 19-02-2020 Chrome browser update 83.0.4103.61. https://bugs.chromium.org/p/chromium/issues/detail?id=1084874
Fixed in release from 03-06-2020 (83.0.4103.97)... phew.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants