首页 > Web开发 > 详细

MVC 无刷新文件上传

时间:2018-04-25 16:23:26      阅读:177      评论:0      收藏:0      [点我收藏+]

先上代码 找了好久 不需要使用其他js

 <form target="framFile" action="@Url.Action("OpenXlsx")" method="post" enctype="multipart/form-data">
            <div class="col-md-3"><input type="file" class="btn" name="file" /></div>
            <div class="col-md-2" style="margin-left: 200px;margin-top: 11px;">
                <input type="submit" class="btn btn-primary btn-flat" value="确认导入" />
            </div>
        </form>
<iframe id="framFile" name="framFile" style="display:none;"></iframe>

原理:

  把form需要提交的内容交到iframe处理 使iframe自行刷新处理

具体可以参考:

https://blog.csdn.net/moyanxuan_1993_2_24/article/details/47172155

 

留个心眼 : jquery-from-js 也是可以得 因为上网查了下target属性好像不太兼容

 

MVC 无刷新文件上传

原文:https://www.cnblogs.com/hutianchang/p/8945224.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!