Zar*_*ara 2 html c# asp.net-mvc openfiledialog button
我想使用下面的按钮打开文件对话框来选择一个/多个单词文件。我还希望它像一个返回路径的方法,以便我可以读取/加载该数据。
<div>
<div class="col-lg-6 col-md-6 col-sm-6">
<img class="img-analyse" src="~/Content/open-file_icon.png">
<button class="button-analyse"onclick="SelectFile">b</button>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我该如何继续?我要注册一个动作事件吗?抱歉,我是 ASP.NET 的初学者。
您可以使用代理文件上传控件
$("#btnSelect").click(function() {
var $input = $('<input type="file" />');
$input.change(function() {
console.log("selected file:" + $(this).val());
});
$input.trigger('click');
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-lg-6 col-md-6 col-sm-6">
<button class="button-analyse" id="btnSelect">select file</button>
</div>Run Code Online (Sandbox Code Playgroud)
这是给你的小提琴:http://jsfiddle.net/CSvjw/2034/
| 归档时间: |
|
| 查看次数: |
5269 次 |
| 最近记录: |