I'm having trouble with the upload module.

"Attach new file" doesn't work in Firefox (Win 1.5.0.7) when javascipt is turned on: Just the loading bar and then nothing, no javascript error is logged. With javascript turned off it works.

Opera (Win 9.02) shows a blank javascript error alert on the first file that is added, but the file still gets added. When adding additional files there is no error.

Internet Explorer (Win 6) works without any error.

In case this can't be duplicated, feel free to remove the "critical" priority.

CommentFileSizeAuthor
#11 opera_upload_hack.patch.txt790 bytesHeine
#7 opera.upload.error.png27.94 KBRobRoy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webernet’s picture

Priority: Critical » Normal

Could not reproduce with Firefox 2 or 1.5.0.7.

Gurpartap Singh’s picture

Opera give error for first uploaded file:
An error occurred:
and nothing else. No errors on next uploads.

Can't reproduce on Firefox 2.

On IE6 (IE Tab), the file remains uploading. No response.

worldcoast’s picture

without getting into end user support, it may be your Java I've run into similar problems with my company website, disabling a particular java plugin in the browser and letting it be handled outside of the browser will make it work often.

Also try upgrading to the latest version of Java if you have not already.

In firefox:

Tools>Options>Content to make sure Java is enabled.

Gurpartap Singh’s picture

How's Java interrupting Javascript?

kkaefer’s picture

Status: Active » Closed (won't fix)

I tested with both uid=1 and other users with less rights and could not reproduce the bug in Firefox 2 (Mac OS), Firefox 1.5 and 1.0.8 (Windows) and IE 6 and 7 (Windows).

Please reopen this issue only if you found the bug (if there is one) or if you know how to reproduce this bug on an arbitrary installation.

anders.fajerson’s picture

Title: AJAX upload broken in Firefox and Opera » AJAX upload gives blank javascript error in Opera
Version: x.y.z » 5.x-dev
Status: Closed (won't fix) » Active

It still doesn't work on my installation of Firefox 1.5.0.8 on Win (tested in safe-mode, all extensions off). Firefox 2 works. As it couldn't be reproduced in Firefox 1.5 I instead focus this issue on the Opera bug, which was reproduced (hope that's ok):

"Opera (Win 9.02) shows a blank javascript error alert on the first file that is added, but the file still gets added. When adding additional files there is no error."

RobRoy’s picture

FileSize
27.94 KB

I can confirm this bug in Opera. The first upload gives an undefined JS error, while subsequent uploads do not. All uploads go through fine though, just have that first error coming up.

Opera Version: 9.00
Build: 8502
System: Windows XP

Heine’s picture

Opera 9 comes with an Error Console at Tools » Advanced » Error console. It's output:

JavaScript - http://head.localhost/node/add/page
Event thread: load
Error:
name: TypeError
message: Statement on line 51: Could not convert undefined or null to object
Backtrace:
  Line 51 of linked script http://head.localhost/misc/drupal.js
    button.form.action = action;
  Line 1 of  script 
    window.iframeHandler();
  At unknown location
    [statement source code not available]
Heine’s picture

Please disregard the above message. It does not occur on all errors.

Heine’s picture

The problem seems to be that drupal.js's Drupal.redirectFormButton receives an empty response (response = (iframe.contentWindow || iframe.contentDocument || iframe).document.body.innerHTML;) first.

Heine’s picture

FileSize
790 bytes

This is weird. iframeHandler is actually called twice when uploading the first attachment. The first time it receives the 0 response. Even stranger, when I add an alert('msg') before grabbing the response, the proper data is received and no error occurs. I've contacted Opera ASA to see if they can shed a light on this. In the mean time, here's a hack.

Gurpartap Singh’s picture

Status: Active » Needs review

This issue is still active in 5.x.

robomalo’s picture

I can also confirm this bug.

Details:

  • Drupal 5.1
    • Upload module
  • Opera 9.10 (Windows)
    • Empty javascript error
    • File still uploads
  • Firefox 2.0.0.3 (Windows)
    • Progress bar sticks, animation keeps going
    • No attachment
  • IE6
    • Progress bar sticks, animation keeps going
    • No attachment
    • Error in status bar "Object doesn't support this property or method"
dharamgollapudi’s picture

Subscribing to see the fix for bug in Opera on Windows........

dharamgollapudi’s picture

Subscribing to see the fix for bug in Opera on Windows........

dharamgollapudi’s picture

Subscribing to see the fix for bug in Opera on Windows........

dharamgollapudi’s picture

I just realized that the patch is posted at http://drupal.org/node/156430

Heine’s picture

Version: 5.x-dev » 6.x-dev
Heine’s picture

Related and perhaps containing a fix (somwhere in the patch): http://drupal.org/node/152378

Heine’s picture

Looking at http://drupal.org/node/152378:

action = button.form.action;
target = button.form.target;

The code here doesn't matter. Anything that generates an error eg:

blah = nonsense

Will 'fix' the undefined error alert in Opera, while uploads still work.

Junyor’s picture

Opera Software has analyzed this issue and determined that it's not a bug. Opera has a non-blocking script engine, which means that Opera starts loading immediately when the script requests it. Gecko will fire 2 load events and fail like Opera if the form submit is delayed long enough.

GoofyX’s picture

I'm using Drupal 5.2 and I've been experiencing this issue. Opera 9.24 on Linux fails, where Firefox 2.0.0.8 succeeds and I'm getting this error message. The file seems to be uploaded, however it is not found in the files directory, although the page is refreshed and displays the file as attached.

Is there a solution for this?

emok’s picture

Is there a solution for this?

Well, for me with Opera 9.25 (on Ubuntu Linux 7.10) the patch in #17 (or #11 which is equivalent) solved it. With Firefox 2.0.0.11 it worked both before and after the patch for me.
Is it reasonable to hope for this to be applied to Drupal 5.x if we get it reviewed to ensure that it doesn't break anytning? I don't know much about the release policies.

ufku’s picture

Could this(http://www.nabble.com/JQuery-Form-Plugin-returns-nothing-in-Opera-td1712...) be related?

Jquery.form plugin that is included in Drupal6 is buggy on Opera 9.2.x

DerekAhmedzai’s picture

This still happens in Opera 9.51

NaX’s picture

If you look at the link from #24, they resolved the problem and malsup gives a link to a newer version of jquery.form.
In that file I found some interesting code.

function cb() {

  ...

  if (doc.body == null && !operaHack && $.browser.opera) {
      // In Opera 9.2.x the iframe DOM is not always traversable when
      // the onload callback fires so we give Opera 100ms to right itself
      operaHack = 1;
      cbInvoked--;
      setTimeout(cb, 100);
      return;
  }

  ...
  
}

I think this is related to what Heine was talking about in #10 and #11.

NaX’s picture

In Opera 9.62 and D5.11 using the Opera error console I get this :

Event thread: load
Error:
name: SyntaxError
message: Statement on line 131: Syntax error
Backtrace:
  Line 131 of linked script http://example.com/misc/drupal.js
      return eval('(' + data + ');');
  Line 68 of linked script http://example.com/misc/drupal.js
            response = Drupal.parseJson(response);
  Line 1 of function script 
    window.iframeHandler();
  ...
stacktrace:   ...  Line 68 of linked script http://example.com/misc/drupal.js
            response = Drupal.parseJson(response);
  Line 1 of function script 
    window.iframeHandler();
  ...

Same error if I use Heine's hack.

It looks to me like the data might be come through wrong.

datacompboy’s picture

I have spend lot of time yesterday, and have found core of trouble.
The core problem, is jquery.form.js when you upload, _requires_ reply to be of type text/html and wraps script/json into !
// wrap json in a textarea if the request did not come from xhr
Here is their source: http://malsup.com/jquery/form/files-raw.php

I have digged a bit more, and found, that opera and ff works fine if reply come with text/javascript, but then jquery.from.js need to be patched a bit:

if (opts.dataType == 'json' || opts.dataType == 'script') {
                    var ta = doc.getElementsByTagName('textarea')[0];
                    xhr.responseText = ta ? ta.value : xhr.responseText;
}

now looks like

if (opts.dataType == 'json' || opts.dataType == 'script') {
                    var ta = doc.getElementsByTagName('textarea')[0];
                    var pre = doc.getElementsByTagName('pre')[0];
                    xhr.responseText = ta ? ta.value : pre ? pre.innerHTML : xhr.responseText;
}

== that fix allows to upload module and ahah_helper works fine for me in opera/ff (we doesn't support IE on that project)

But to fix problem for all browsers, here two way to fix.
Fix #1: without any patches to jquery.form.js, needs to patch drupal_json function:

function drupal_json($var = NULL) {
  // We are returning JavaScript, so tell the browser. But, if request was POST and not with XMLHttpRequest, then it 
  // come from jquery.form plugin, and needs to be fixed
  if ($_SERVER["REQUEST_METHOD"]=="POST" && $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') {
    drupal_set_header('Content-type: text/html; charset=utf-8'); 
    echo "<textarea>";
  } else 
    drupal_set_header('Content-Type: text/javascript; charset=utf-8');

  if (isset($var)) {
    echo drupal_to_js($var);
  }
}

Fix #2: Patch jquery.from.js as above + fix drupal_json like above, but instead text/html use text/plain and remove output of tag.

vietcoop’s picture

Priority: Normal » Critical

This still happens in Opera 10.0

donquixote’s picture

Could it be that Opera does not like the < and > being escaped as \x3c and \x3e in drupal_to_js? For instance, PHP's json_decode() does not like it either.

See also #434394: 'HTTP error 0 occurred' on image upload

I don't know what web standards say about json syntax. Maybe the other browsers are just more tolerant?

donquixote’s picture

#11 is on the right track I think.

There is some interesting info in this thread,
#434394-110: 'HTTP error 0 occurred' on image upload and further down.

Apparently there are two unrelated problems, that just have some similar symptoms:
a) problems with memory_limit on shared hosting
b) a quite obvious bug in jquery.form.js. The problem here is that the iframe onload event can fire for an empty iframe.

andypost’s picture

subscribe

datacompboy’s picture

Just updated to Drupal 6.14, in opera 10 no bug with fix№1 from comment #28

donquixote’s picture

@datacompboy (#33):
Can you check which flavor of this bug is solved with your fix?
#434394-157: 'HTTP error 0 occurred' on image upload

Alex Andrascu’s picture

subscribe. same problem

datacompboy’s picture

Sorry for long delay before answer, i was out :)

Of course, since it get fixed by server-side, it fixes server-side issue. BTW, "a) With the client-side / javascript issue, you get the error message immediately after clicking "upload"." is really also server-side problem, just if you tries to upload little image or on fast connection.

Have updated drupal to 6.19. Fix in common.inc for drupal_json works like a charm.

dpearcefl’s picture

Priority: Critical » Normal
Status: Needs review » Postponed (maintainer needs more info)

Has this issue been fixed in the latest D6?

dpearcefl’s picture

Priority: Normal » Major
Status: Postponed (maintainer needs more info) » Needs work

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.