Defect #14953

Intermittent AJAX Atttachement Upload Failure in Firefox

Added by Charlie Beckett about 4 years ago. Updated about 3 years ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:


Target version:-
Resolution: Affected version:2.3.2


(Firslty, thanks to all involved in this great product)

I'm running Redmine v2.3.2 under Windows Apache with ModSSPI (for NTLM) and thin.
The AJAX Document upload works perfect in IE and Chrome but intermittently fails in Firefox.

The first upload can succeed, then adding more documents results in 'error' appearing in the Optional Description element and the document fails to upload.

Looking at the Apache access logs it appears that the problem is related to authentication; with the working attempts logging user IDs and the failed attempts without. With Chrome you can see 2 attempts and the third attempt authenticating, in IE, you see nothing.

I've tried setting SSPIPerRequestAuth but that's made no difference. Help greatly appreciated.

Related issues

Related to Redmine - Defect #6089: Large uploads fails with Firefox New 2010-08-09


#1 Updated by Charlie Beckett almost 4 years ago

Is there any easy way to more to fallback to the none ajax method whilst I investigate ?

#2 Updated by Thomas Löber almost 4 years ago

Hi Charlie,

I have also experienced upload failures when there was too much time between two uploads.

The problem seems to be that the AJAX POST request (in contrast to GET) doesn't try to re-authenticate when the connection to the server was closed after some time of inactivity.

However I was able to build a workaround by issuing an AJAX GET request in case of failure and then try the upload (POST) again:

--- public/javascripts/attachments.js.orig
+++ public/javascripts/attachments.js
@@ -53,6 +53,12 @@
         fileSpan.find('input.description, a').css('display', 'inline-block');
       .fail(function(result) {
+        if (result.status == 0 && result.statusText == "error") {
+          var url = $(inputEl).data("upload-path").replace(/^\/([^/]+).*/, "/$1/authenticate.txt");
+          $.ajax({url: url, cache: false}).
+            done(function() { actualUpload(file, attachmentId, fileSpan, inputEl); });
+          return;
+        }
       }).always(function() {

You will have to create an empty file authenticate.txt in public for this to work.

Best regards,

#3 Updated by Thomas Löber almost 4 years ago

I have just seen that the regexp above handles the Rails URL prefix. If you do not use this feature you may use "/authenticate.txt" directly:

var url = "/authenticate.txt";

#4 Updated by Charlie Beckett almost 4 years ago

Hi Thomas
Thanks for helping with this. This seems to work really well in IE, but now the file doesn't upload in Firefox and Chrome reports "Not Acceptable" after several tries.

#5 Updated by D G almost 4 years ago

Same problem here. Redmine 2.4.1 + Kerberos. Until this error is fixed we use included fallback form submission:

--- public/javascripts/attachments.js   (revision 12347)
+++ public/javascripts/attachments.js   (working copy)
@@ -117,19 +117,12 @@
 function addInputFiles(inputEl) {
   var clearedFileInput = $(inputEl).clone().val('');

-  if (inputEl.files) {
-    // upload files using ajax
-    uploadAndAttachFiles(inputEl.files, inputEl);
-    $(inputEl).remove();
-  } else {
-    // browser not supporting the file API, upload on form submission
     var attachmentId;
     var aFilename = inputEl.value.split(/\/|\\/);
     attachmentId = addFile(inputEl, { name: aFilename[ aFilename.length - 1 ] }, false);
     if (attachmentId) {
       $(inputEl).attr({ name: 'attachments[' + attachmentId + '][file]', style: 'display:none;' }).appendTo('#attachments_' + attachmentId);
-  }


#6 Updated by Ebrahim Mohammadi about 3 years ago

Related: #6089

#7 Updated by Toshi MARUYAMA about 3 years ago

  • Related to Defect #6089: Large uploads fails with Firefox added

Also available in: Atom PDF