Discussion:
[Dojo-interest] dojox.form.FileUploader
Andre Juffer
2011-07-28 15:43:29 UTC
Permalink
Hi,

I've some trouble with the (incomplete) code below to upload a single
image file. The main problem is that I never see the uploader to appear
on the screen (neither in Firefox, Explorer, etc). The code below is
basically adapted from the example given at

http://dojotoolkit.org/reference-guide/dojox/form/FileUploader.html#setup

I must be missing something, but I do not see it. Hopefully one of you
can give me a hint. With firebug I can see that the uploader is created,
but I don't think that the button is actually created. Also, the text of
the button 'selectButton' (see below) is not visible. No errors are
reported by Firebug. Note that I use Dojo 1.5 and I include the
following as well (with @include and <script type="text/javascript">):

dojox/form/resources/FileUploader.css
dojox/form/FileUploader.js
dojox/embed/flashVars.js
dojox/embed/Flash.js

(note sure whether the above is in fact necessarily. In any case, it has
no effect at all.).

(Anything missing? As I will -not- use flash, I did not include
dojox/form/resources/uploader.swf
)

<code>

// Note: Workspace is a dijit.layout.ContentPane
var imageUpload = dojo.create("div", {}, "workspace");

var selectButton = dojo.create("div", {
innerHTML: "Select Equipment Image"
}, imageUpload);

var fileToUpload = dojo.create("textarea", {}, imageUpload);

var uploadButton = new dijit.form.Button({
label: "Upload Selected Image",
});
imageUpload.appendChild(uploadButton.domNode);

var fileMask = [
["Jpeg File", "*.jpg;*.jpeg"],
["GIF File", "*.gif"],
["PNG File", "*.png"],
["All Images", "*.jpg;*.jpeg;*.gif;*.png"]
];

var uploadUrl = "";

var uploader = new dojox.form.FileUploader({
uploadUrl: uploadUrl,
uploadOnChange: false,
selectMultipleFiles: false,
fileMask: fileMask,
force: "html",
}, selectButton);

dojo.connect(uploader, "onChange", function(dataArray){
dojo.forEach(dataArray, function(data){
fileToUpload.value += data.name + " " +
Math.ceil(data.size * 0.001) + "kb \n";
});
});

uploader.startup();

</code>

Thanks,
--
Andre H. Juffer | Phone: +358-8-553 1161
Biocenter Oulu and | Fax: +358-8-553-1141
Department of Biochemistry | Email: ***@oulu.fi
University of Oulu, Finland | WWW: www.biochem.oulu.fi/Biocomputing/
StruBioCat | WWW: www.strubiocat.oulu.fi
NordProt | WWW: www.nordprot.org
Triacle Biocomputing | WWW: www.triacle-bc.com
ahjuffer
2011-08-03 12:14:51 UTC
Permalink
To answer my own question about the dojox.form.FileUploader, after switching
to dojo 1.6.1, it appears that one must call the show() method. Thus, after
uploader.startup() (see code), include uploader.show() as well. Both the
text in the button is now visible and the uploader dialog appears on the
screen.

It would be useful to mention this in the documentation.

Thanks.

--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/dojox-form-FileUploader-tp3207128p3222070.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
ahjuffer
2011-08-03 12:22:22 UTC
Permalink
Small correction. The uploader.show() did NOT solve the issue. Switching to
1.6.1 resolved it. The show() method does not exist for the uploader.

--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/dojox-form-FileUploader-tp3207128p3222086.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
Gxwilson
2011-08-07 08:02:08 UTC
Permalink
Is there no way to get this to work in 1.5?

--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/dojox-form-FileUploader-tp3207128p3232685.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.

Loading...