Andre Juffer
2011-07-28 15:43:29 UTC
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,
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
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