我希望用户能够点击我的应用的标签1上的图片,该标签将打开文件浏览器以启用照片上传。这可能吗??
答案 0 :(得分:2)
是
<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap" />
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" href="javascript: document.getElementById('files').click()" alt="Sun" />
<area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury" />
<area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus" />
</map>
<form>
<input type="file" id="files">
</form>
当您单击地图的“太阳”区域时,这将加载文件浏览对话框。
或者,参考问题的正文(没有图像地图)
<script type="text/javascript" language="javascript">
function showFileBrowser()
{
//maybe do something here
var fb = document.getElementById('files');
fb.click();
}
</script>
...
<img src="src.ext" alt="a picture" onclick="showFileBrowser()" />
...
<form action="something" method="post">
<input type="file" id="files" />
</form>