官网:
 
HTML页面:
引用:
<link href="~/BootstrapComponent/css/fileinput.css" rel="stylesheet" />
<script src="~/BootstrapComponent/js/fileinput.js"></script>
<script src="~/BootstrapComponent/js/locales/zh.js"></script>
<!--容器-->
<input id="inputFile" type="file" class="file" data-preview-file-type="text" name="file">
<!--JS代码-->
<script>
//初始化fileinput控件
$("#inputFile").fileinput({
language: 'zh',
autoReplace: false,
maxFileCount: 1,
allowedFileExtensions: ["jpg", "png", "gif"],
browseClass: "btn btn-primary", //按钮样式
previewFileIcon: "<i class='glyphicon glyphicon-king'></i>"
});
</script>
fileinput.js文件参数修改:
$.fn.fileinput.defaults = {
language: 'en',
showCaption: true,
showBrowse: true,
showPreview: true,
showRemove: true,
showUpload: false, //若为同步提交,无需显示组件的上传按钮
showCancel: true,
showClose: true,
   ...
  }
MVC控制器:
        /// <summary>
/// MVC文件上传后台方法
/// </summary>
/// <returns></returns>
public JsonResult FileUpload()
{
string text = "位置错误!";
bool isSuccess = false;
var files = Request.Files;
if (files != null && files.Count > )
{
try
{
var file = files[];
var fileName = file.FileName;
var filePath = Path.Combine(HttpRuntime.AppDomainAppPath, "image", fileName); //绝对路径
file.SaveAs(filePath);
isSuccess = true;
text = "上传成功!";
}
catch (Exception e)
{
text = e.Message;
}
}
return Json(new { Success = isSuccess, Message = text }, JsonRequestBehavior.AllowGet);
}

最新文章

  1. PHP开发中的缓存技术汇总
  2. 添加了有道生词本的 chrome google翻译扩展和有道翻译扩展
  3. WinForm 使用 HttpUtility
  4. Linux:系统的密码忘记了,登录不上
  5. Windows Embedded Compact 2013升级:VS2013也能编译
  6. cache—主存—辅存三级调度模拟
  7. AFNetworiking与ASIHttpRequest对比
  8. 怎样在小方框上打对号 小方框内打对勾 word 方框打对勾
  9. javaweb利用filter拦截请求
  10. 基本数据类型 字典 dict
  11. 深度学习(PYTORCH)-3.sphereface-pytorch.lfw_eval.py详解
  12. 常用nginx rewrite重定向-跳转实例:
  13. HashMap实现原理分析--面试详谈
  14. js上传插件uploadify自动检测不到flash控件的问题
  15. tengine 增加ngx_http_cache_purge_module 模块
  16. vlc 网页插件的 使用与控制 API http://www.xuebuyuan.com/2224602.html
  17. php上传文件涉及到的参数
  18. 使用AHKActionSheet
  19. 【CF739E】Gosha is hunting(动态规划,凸优化)
  20. 视图 b

热门文章

  1. m_Orchestrate learning system---十六、如何快速在一堆字符图标中找到所需
  2. php 设计模式之观察者模式(订阅者模式)
  3. hdoj--1384--Intervals(差分约束)
  4. caffe中LetNet-5卷积神经网络模型文件lenet.prototxt理解
  5. html单行、多行文本溢出隐藏
  6. 图论之tarjan缩点
  7. oracle 11g rac for linux add node (oracle 11g rac 节点添加)
  8. 10:Challenge 3(树状数组直接修改)
  9. the prblem 3n+1
  10. Spring Framework 开发参考手册中文(在线HTML)