Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open File Dialog box on <a> tag

I want to have an Open File dialog box on a link in my webpage.

I tried

<input name="uploadedfile" type="file">

but, it works as a button. And, doesn't allow to select multiple files.

I want to have something like

<a href="#" onclick="some_function_for_OpenFileDialogBox">Upload Files</a>

Please suggest.

Thank You

Kaur

like image 660
kaur Avatar asked Apr 18 '12 19:04

kaur


People also ask

How do I open a dialogue in HTML?

Use the type="file" Attribute in HTML and onchange Method in JavaScript to Open File Dialog. We will create a button element in the following instance, and an onclick attribute will follow this. This will trigger a function in the JavaScript file.

How do I open file upload dialog box on image click?

And on the button's click event write the jQuery code like : $('#OpenImgUpload'). click(function(){ $('#imgupload'). trigger('click'); });

How do I open a dialogue file?

OpenFileDialog component opens the Windows dialog box for browsing and selecting files. To open and read the selected files, you can use the OpenFileDialog. OpenFile method, or create an instance of the System.


1 Answers

You can only open a "Open File" dialog using a input type=file tag. However the efect you are looking for can be accomplished like this :

<input type="file" id="upload" name="upload" style="visibility: hidden; width: 1px; height: 1px" multiple />
<a href="" onclick="document.getElementById('upload').click(); return false">Upload</a>
like image 124
d4rkpr1nc3 Avatar answered Oct 11 '22 18:10

d4rkpr1nc3