File Open Dialog Box through JavaScript


I want to call File Open Dialog Box on a Hyperlink Click, for Attachment of File as you can see this functionality in GMAIL for Attachment of Files.

Amrat Nandlal

curiously enough this works with IE …

<input type="file" style="display:none;" id="inputfile"/>
<a href="javascript:document.getElementById('inputfile').click(); ">try this</a>

You could also do something like this:

On your “Main page” insert this code

<script type="text/javascript">

        function UploadWindow(URL) {

                 var Upload =,"",




<A HREF="javascript:UploadWindow('UploadWindow.html')">Click here to attach file:</A>

Copy/Paste the following code and save it as UploadWindow.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<TITLE>Upload Page</TITLE>
<BODY bgcolor="#FFFFFF" text="#000000">

Select file to upload:
<INPUT type="file" size="50" name="FileName">


I was wondering how Gmail did it in IE. Of course it doesn’t do this in Firefox… Then it becomes simple and plain. Thx for the input.