我的最终游戏是将上传者添加到对话框中。那行不通,所以我走了简单的路线,看看它是否可行。下面是我可以做到的尽可能简单,遗憾的是,单击按钮时文件选择器不显示。我在 Firefox 和 Chrome 中工作。如果有人愿意仔细检查并找到一个傻瓜,我将不胜感激。
require(["dojox/form/Uploader",
"dojo/dom",
"dojox/form/uploader/plugins/IFrame",
"dojo/domReady!"
],
function(Uploader, dom) {
var u = new Uploader({
name: "myPhoto",
label: "Upload Your Photo",
multiple: false,
uploadOnSelect: true,
url: "to/the/ethreal"
});
dom.byId("myDiv").appendChild(u.domNode);
});
<html>
<head>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dijit/themes/claro/claro.css" media="screen">
<!-- load dojo and provide config via data attribute -->
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojo/dojo.js" data-dojo-config="async: true"></script>
</head>
<body class="claro">
<div id="myDiv"></div>
</body>
</html>