1、jquery.form附件上传
来源:互联网 发布:淘宝上买东西怎样付款 编辑:程序博客网 时间:2024/05/02 00:15
1、将jquery及jquery.form引用进来
<script src="~/Content/JQuery/jquery-1.8.2.js"></script> <script src="~/Content/JQuery/jquery.form.js"></script>
2、html页面代码
<form id="ajaxForms" enctype="multipart/form-data"> <input id="Files" name="Files" type="file" class="file" /> <input id="Button1" onclick="Fn_UpLoad()" type="button" value="上传附件" /> </form> <table id="List"></table>
3、js前台代码
function Fn_UpLoad() { if (document.getElementById("Files").value) { $("#ajaxForms").ajaxSubmit({ type: "POST", url: "/Form/Fn_UpLoad?SaveModuleName=TestFile", dataType: "text", success: function (data) { $("#List").append("<tr><td>" + data + "</td></tr>"); } }); } else { alert("请选择附件!"); return; } }
4、MVC后台代码
public ActionResult Fn_UpLoad() { HttpPostedFileBase files = Request.Files["Files"]; string FileName = files.FileName; string SaveModuleName = Request["SaveModuleName"].ToString();//文件存放模块 string FilesPath = System.AppDomain.CurrentDomain.BaseDirectory + "Attachment\\" + SaveModuleName;//文件存放路径 //判断文件存放模块是否存在 if (Directory.Exists(FilesPath) == false) { Directory.CreateDirectory(FilesPath); } //判断文件是否 if (System.IO.File.Exists(FilesPath + "\\" + FileName) == false) { files.SaveAs(FilesPath + "\\" + FileName); } return Content(FilesPath + "\\" + FileName); }
6、源代码
本例子源代码
0 0
- 1、jquery.form附件上传
- 使用 jquery.form.js插件上传带有附件的表单
- form表单提交上传附件
- Jquery 多附件上传
- maximo7.1上传附件
- jquery.form实现文件上传
- Jquery.form.js 上传图片
- HTML5开发必备jquery上传附件功能
- 附件上传form request.getParameter无法获取参数值解决方法
- form表单+servlet实现文件(附件)上传
- form表单上传附件的几种方法
- jquery Ajax提交表单(使用jquery Ajax上传附件)
- jquery Ajax提交表单(使用jquery Ajax上传附件)
- jquery Ajax提交表单(使用jquery Ajax上传附件)
- 上传附件
- 附件--上传
- 附件上传
- 附件上传
- spring mobile简单试用
- DOM 操作技术之动态样式
- mac上访问samba服务器
- vc6.0快捷键
- C - The C Answer (2nd Edition) - Exercise 1-1
- 1、jquery.form附件上传
- centos6.2 下安装mysql5.5
- 输出四位数中所有吸血鬼数 [java重学]
- linux网络基础
- Android数据库缓存
- DDL触发器引起的ORA-06512 (同时兼有ORA-00376)
- poj 3782 LCA+树链剖分
- 树王
- Android数据库缓存