Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8005141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:08:32+00:00 2026-06-04T17:08:32+00:00

Possible Duplicate: Jquery trigger file input I’m working on a form which allows users

  • 0

Possible Duplicate:
Jquery trigger file input

I’m working on a form which allows users to upload images to a website. So far I have got a drag and drop solution working in Chrome and Safari. However I also need to support the action of users clicking a button and browsing for files in the traditional manner.

Similar to what this would do:

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

However rather than having the clunky file description area and un-editable Browse button I would rather use something like this:

<input type="button" id="get_file">

My question therefore is how to I make this button open a file selection window and process the selection the same way that type="file" would work?

Cheers.


My Solution

HTML:

<input type="button" id="my-button" value="Select Files">
<input type="file" name="my_file" id="my-file">

CSS:

#my-file { visibility: hidden; }

jQuery:

$('#my-button').click(function(){
    $('#my-file').click();
});

Working in Chrome, Firefox, and IE7+ so far (haven’t tried IE6).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:08:34+00:00Added an answer on June 4, 2026 at 5:08 pm

    You could use JavaScript and trigger the hidden file input when the button input has been clicked.

    http://jsfiddle.net/gregorypratt/dhyzV/ – simple

    http://jsfiddle.net/gregorypratt/dhyzV/1/ – fancier with a little JQuery

    Or, you could style a div directly over the file input and set pointer-events in CSS to none to allow the click events to pass through to the file input that is “behind” the fancy div. This only works in certain browsers though; http://caniuse.com/pointer-events

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: jQuery: get the file name selected from <input type=file /> I have
Possible Duplicate: jQuery : simulating a click on a <input type=“file” /> doesn't work
Possible Duplicate: jQuery event to trigger action when a div is made visible How
Possible Duplicate: JQuery validate e-mail address regex hi i have an input filed in
Possible Duplicate: jquery .bind() and/or .ready() not working Why is there a difference in
Possible Duplicate: jquery trigger - ‘change’ function I have a radio button set called
Possible Duplicate: jQuery attribute selector for multiple values I have this $('input:radio[name=foo]').change(function() { blah();
Possible Duplicate: jQuery refresh if PHP file echo's 'true' I have the following div
Possible Duplicate: jQuery: How to determine which <li> tag was clicked? I have a
Possible Duplicate: Jquery event on a disabled input I am making an edit dialog

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.