#15151 closed defect (fixed)
UploadFile.php not working on single file uploads
Reported by: | adlerweb | Owned by: | Mike Wilcox |
---|---|---|---|
Priority: | undecided | Milestone: | 1.9 |
Component: | DojoX Uploader | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
When feeding UploadFile?.php from a source using "HTML single POST" (like "Inline Browse Button Form Post Test" from test_Uploader.html) the upload itself works but dojo does not recognize the successful completion (i guess onComplete() doesn't get fired). Firefox' error console shows "JSON.parse: unexpected character".
For reference here an UploadFile?.php-Output in case of the named "HTML single POST" (multiple="false") captured by HttpFox?:
<textarea style="width:600px; height:150px;">{"file":"..\/tests\/uploads\/test.jpg","name":"test.jpg","width":2272,"height":1704,"type":"jpg","size":2060485,"additionalParams":{"album":"Summer Vacation","year":"2011"}}</textarea>
This output is sent back on multi file uploads using "HTML5 multi file input" (multiple="true"):
[{"file":"..\/tests\/uploads\/test.jpg","name":"test.jpg","width":300,"height":259,"type":"jpg","size":20624}]
As you can see the correctly working multi-upload does not return the JSON-Data inside a <textarea> - i guess the http-post-tree is missing a return-function like on other methods. If i add the following lines at line 290 (current git) it seems to work.
+
+ $data = $json->encode($htmldata);
+ trace($data);
+ print $data;
+ return $data;
Note: Other methods like rmFiles also got no return on success - i have not tested but i guess these are broken too. Is this whole <textarea>-JSON-Wrapping even applicaple with current dojo?
Change History (11)
comment:1 Changed 8 years ago by
comment:2 Changed 8 years ago by
Status: | new → assigned |
---|
One thing I found while testing this is that Uploader does not work perfectly with AMD. So this fails:
data-dojo-type="dojox/form/Uploader"
But this works:
data-dojo-type="dojox.form.Uploader"
adlerweb, I think that might help you. If you are getting a textarea, something is wrong, that's only for iframes.
jeff_l, your code seems to work. Please check the server is handling the request properly.
Test that you have the uploader plugin that you expect:
var u = dijit.byId('uploader'); console.log(u.uploadType);
comment:3 Changed 8 years ago by
mwilcox, thanks for looking into this. When I added your suggested diagnostic code, just after the closing </div> in my excerpt above, I saw the following error in the console: "u is undefined"
comment:4 Changed 8 years ago by
Oh, that might not have happened at the right time. Here is more fleshes out code:
function(dojo, Button, Uploader, FileList, uFlash, dr, parser){ parser.parse(); /// <----------------- after this var u = dijit.byId('uploader'); console.log(u.uploadType, u); });
comment:5 Changed 8 years ago by
mwilcox, sorry for being such a dimwit, but my app doesn't have anyplace where it does an explicit parse(), so I'm not seeing an obviously correct place to insert the "var u" assignment.
comment:6 Changed 8 years ago by
How are you parsing your widgets? Are you using the old renderer with parseOnLoad=true in dojoConfig? You could put it on dojo.ready();
You also could just use a setTimeout since this is just for debugging.
comment:7 Changed 8 years ago by
Yes, we're specifying parseOnLoad=true in dojoConfig. Following your suggestions, I messed around with dojo.ready() and setTimeout() but it's not cooperating, probably since I don't really know what I'm doing.
Before I burn out your patience -- Is there one very specific step I could take to try to debug this problem? And please don't worry about offending me by being explicit, spelling things out as you would to a nearly complete newbie at Dojo and JavaScript?. I've been doing industrial Java for a couple of decades, but am still getting the hang of this Web stuff.
comment:8 Changed 8 years ago by
We solved our problem. It turned out that we had neglected to include a unique session ID in our submitted <form> element. A couple of months ago we added multi-session support to our app, which involved tagging each new browser tab with a unique ID. When we added a hidden <input> with the sessionID, it solved the problem. mwilcox, thanks for your suggestions along the way.
comment:9 Changed 8 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I fixed the line of code that was append s[] to the filename to do it even if it is single file. This works, but may cause troubles backcompat with current workarounds.
comment:10 Changed 8 years ago by
Milestone: | tbd → 1.9 |
---|
comment:11 Changed 8 years ago by
Not happy with the solution of always adding "s[]". I can't configure the attribute name any more which breaks my app. I don't want to change my server to accept an array of files, it only supports single uploads.
I have a similar problem, that seems to have developed within the past couple of months. As of last July, the following chunk of code was rendering just fine, but now I can't manage to get the onComplete event to fire, no matter what combination of plugins I require (HTML5, IFrame, Flash) as described in http://dojotoolkit.org/reference-guide/1.8/dojox/form/Uploader.html . We're on Dojo 1.7, and using the latest versions of Firefox and IE9. Perhaps something has changed recently in the browsers.