This question already has answers here:
Open file dialog box in JavaScript
(11个答案)
3年前关闭。
随着网络应用程序正在开发的学生讨论平台,我希望学生在发布问题时附加文件,我不想使用按钮,
取而代之的是,学生只需单击一个超链接,就会打开上载对话框。
怎么做?
(11个答案)
3年前关闭。
随着网络应用程序正在开发的学生讨论平台,我希望学生在发布问题时附加文件,我不想使用按钮,
取而代之的是,学生只需单击一个超链接,就会打开上载对话框。
怎么做?
最佳答案
您可以在链接内创建文件输入,并以不透明的方式隐藏它:
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>