[Dojo-interest] dojo.iframe.io.send hanging after 1 or 2 file uploads in Safari

Skip to first unread message

Jette Derriche

Sep 28, 2009, 4:35:56 AM9/28/09
to Dojo Interest

Last week I made a post about dojo.iframe.io.send and Safari on Mac. I
thought it was solved, but now I have new information.

When uploading a file using Safari on Mac, it works the first time, and
maybe a second time. After that, the next upload just hangs.

This leads me to believe that I need to reset something. I just don't
know how and what. Any ideas?

The test was done in Safari v4 with dojo v1.2.3.

Here is a complete test case (remember to correct your paths to dojo).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<title>dojo.io.iframe.send test case</title>
<link rel="stylesheet" type="text/css"
<link rel="stylesheet" type="text/css"
<script type="text/javascript" src="dojo1/dojo/dojo.js"
djConfig="parseOnLoad: true, locale:'end', usePlainJson: true"></script>
<script type="text/javascript">
function fileupload(formId,functionName) {
form: formId,
handleAs: 'json',
load: function(data){

//Call another function

error: function(data,ioArgs) { alert(data); return data; }

function anotherFunc(data) {
alert('Message from server: '+data.message);
<body style="padding:50px">

<form id="fileupload" method="post" action="serverside.php"
<input name="action" value="fileupload" type="hidden">
<input name="args[recipientId]" value="430" type="hidden">
<input name="args[messageId]" value="1125765" type="hidden">
<input name="args[type]" value="attach" type="hidden">
<input name="file" id="modalFileUploadField" type="file">
<input value="Upload file"
onclick="fileupload('fileupload','anotherFunc')" type="button">


SERVER SIDE (serverside.php):

if (isset($_FILES['file']['size'])) {
$error = '0';
$success = '1';
$msg = 'The FILES array was successfully set';
} else {
$error = '1';
$success = '0';
$msg = 'Failed: no FILES array';
$ary = array('error' => '0','success' => $success, 'message' => $msg);
$retval = json_encode($ary);
$retval =
echo $retval;


FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org

Mike Wilcox

Sep 28, 2009, 7:56:21 AM9/28/09
to dojo-i...@mail.dojotoolkit.org
It works for me in dojo 1.4. There were some changes to the iframe,
but I think it was only for builds.

The only thing I see wrong is that you have two </head> tags.

Sorry that's not much help. Try the trunk and see if it fails there?

Mike Wilcox
Software Engineer
SitePen, Inc.

Jette Derriche

Sep 28, 2009, 12:17:03 PM9/28/09
to dojo-i...@mail.dojotoolkit.org
On man, 2009-09-28 at 06:56 -0500, Mike Wilcox wrote:
> It works for me in dojo 1.4. There were some changes to the iframe,
> but I think it was only for builds.
> The only thing I see wrong is that you have two </head> tags.

No, I have a start-tag, and and end-tag:


Also, it always works the first time (and somtimes the second), so the
return value is probably not the cause.

> Sorry that's not much help. Try the trunk and see if it fails there?

Yeah, I should probably use this as an opportunity to upgrade dojo.

Thank you for taking the time :-)

Jette Derriche

Oct 22, 2009, 6:16:47 PM10/22/09
to dojo-i...@mail.dojotoolkit.org
I have spent many hours on this bug, so I'll probably save someone some
time by posting my solution.

To sum it up, I've been struggling getting file uploads working in
Safari with dojo.io.iframe.send.

It turns out, that the problem is not dojo or using ajax in general. I
noticed that the same error occurred with plain old html file upload

The bug is in the way Safari handles the connection:

I added this to the virtual host in the Apache conf file, and now it
works like a charm:

BrowserMatch Safari nokeepalive

Must say I am surprised that this has been an issue since 2005 :-/

The symptoms of this issue are:

File uploads work sporadically with Safari. The larger the file is, the
more likely it is to fail. The browser seems to do something (the
addressbar says 'Loading...'), but nothing is actually sent to the
server. It fails consistently if the same file (around 1 mb) is uploaded
twice via the same form.


Nicola Piccinini

Nov 14, 2009, 11:26:25 AM11/14/09
to dojo-i...@dojotoolkit.org
Reply all
Reply to author
0 new messages