[英]Asp.net MVC button should open file dialog
我想使用下面的按钮打开文件对话框,选择一个/多个Word文件。 我也希望它像一个返回路径的方法,以便我可以读取/加载该数据。
<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>
我该怎么办? 我要注册一个动作事件吗? 对不起,我是asp.net的一个新手。
您可以使用代理文件上传控制
$("#btnSelect").click(function() { var $input = $('<input type="file" />'); $input.change(function() { console.log("selected file:" + $(this).val()); }); $input.trigger('click'); });
<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>
这是为您准备的小提琴: http : //jsfiddle.net/CSvjw/2034/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.