views:

61

answers:

1

I want the user to be able to click on an image on tab 1 of my app that will open up the file browser to enable a photo to be uploaded. is this possible??

+1  A: 

Yes.

<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>

This will load the file browsing dialog when you click on the "Sun" area of the map.

Or, refering to the body of your question (without an image map)

<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>
Matt Ellen