user1038814
user1038814

Reputation: 9657

input type="file" using link in Jquery

Is it possible to emulate <input type="file"> and get a file browser using a link and jQuery?

I've tried to find a tutorial to do this, but a search on google doesn't show me any answers. Any help will be most appreciated.

Upvotes: 2

Views: 604

Answers (2)

Jon Egerton
Jon Egerton

Reputation: 41549

I've achieved similar in the past but its a bit of a hack:

  • Put a normal fileupload on the page.
  • Make it completely transparent(using opacity - don't change it's visibility to hidden)
  • Position your link under the file upload browse button.

When the user thinks they're clicking on the link, they will actually click the browse button.

Its horrible, but I don't know of another way.

Upvotes: 0

WhyNotHugo
WhyNotHugo

Reputation: 9916

Short answer: no.

file inputs let to browse your disk, etc to select a file. This can't be emulated with any other standard HTML/JS technique.

Upvotes: 2

Related Questions