0

With the web application am developing student discussion platform, I want a student to attach file when posting a question, I do not want to use a button, Instead, a student just clicks a hyperlink and the upload dialog box opens.

How to do it?

mplungjan
  • 155,085
  • 27
  • 166
  • 222
  • Welcome to SO. Please visit the [help] and take the [tour] to see what and how to ask. HINT: Post code and efforts and do take more care when writing. A spell checker plugin would be useful for you. – mplungjan May 23 '16 at 08:57

1 Answers1

1

You can create file input inside link and hide it with opacity:

a {
  position: relative;
}
#file {
  position: absolute;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
  -moz-opacity: 0;
  -khtml-opacity: 0;
  opacity: 0;
  cursor: pointer;
  right: 0;
}
<a href="#"><input type="file" id="file"/>Link text</a>
jcubic
  • 56,835
  • 46
  • 206
  • 357