页面源码:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jquery upload上传文件(asp.net mvc)配置</title>
<script src="Resources/jquery.js"></script>
<script src="Resources/uploadify/jquery.uploadify.js"></script>
<script type="text/javascript">
$(function(){
$("#file-upload").uploadify({
auto: true, // 选择文件后是否自动上传,默认值:true
height: 30, // 按钮高度
swf: '/Resources/uploadify/uploadify.swf', // flash文件路径
uploader: '/home/UploadFile', // 服务器上传地址
width: 120, // 按钮宽度
buttonText: "选择文件", // 按钮显示文本, 默认值:Select File
fileObjName: "uploadFileName", // 服务器接收文件名, 默认值:FileData
buttonClass: "custom-css", // 自定义按钮类样式(追加), 默认值:空
buttonCursor: "arrow", // 鼠标样式, 默认值:hand
buttonImage: null, // 按钮背景图片
checkExisting: false, // 如果为true, 服务器应该提供接口用于检查即将上传的文件是否已存在服务端,
debug: true, // 设置SWFUpload为debug模式
fileSizeLimit: 0, //上传文件大小限制:0无限制, 默认单位KB, 可设置成字符串如:1024MB
fileTypeDesc: "图片文件", // 选择框图片选择描述, 默认值 All Files
fileTypeExts: "*.jpg;*.gif;*.png;*.bmp;*.rar", // 选择文件后缀名过滤, 默认值*.*即所有文件。 多个后缀名采用;隔开
formData: { parameter1: "value1", parameter2: "value2" }, // 每个文件上传 附加的参数(json类型), 默认值:空
itemTemplate: false, //上传文件队列的列表模板,
method: "post", // 提交方式,GET|POST
multi: true, // 是否支持多个文件上传
preventCaching: false, // 阻止缓存
progressData: "percentage", // 进度条显示情况,percentage|speed
queueSizeLimit: 999, // 每次选择上传文件队列的总数大小, 默认值:999
removeCompleted: true, // 文件上传成功后移出队列, 默认值:true
removeTimeout: 3, // 文件上传成功后延迟几秒移出队列, 默认值:3
requeueErrors: false, // 当文件上传发生错误时,如果为true上传动作会重复操作
uploadLimit: 999, // 上传文件的数量最大值,默认值:999
onCancel: function (fileObj) { // 当上传文件从队列移出触发
console.dir(arguments);
},
onClearQueue: function (queueItemCount) { // 当执行清除队列是触发,如$('#file-upload').uploadify('cancel','*')
console.dir(arguments);
},
onDestroy: function () { // 当销毁SWFUpload是触发
console.log("uploadify已被销毁!");
},
onDialogClose: function (queueData) { // 当选择文件对话框关闭时触发
console.dir(arguments);
},
onDialogOpen: function () { // 当选择文件对话框打开时触发
console.dir(arguments);
},
onDisable: function () { // 当调用disable方法时触发, 如:$('#file-upload').uploadify('disable', true);
console.log("uploadify已被禁用!");
},
onEnable: function () { // 当调用disable方法时触发, 如:$('#file-upload').uploadify('disable', true);
console.log("uploadify已被开启!");
},
onFallback: function () { // Flash版本兼容错误 触发
console.log("Flash不兼容!");
},
onInit: function (instance) { // 初始化时触发
console.dir(arguments);
},
onQueueComplete: function (queueData) { // 当队列中所有文件都执行完时 触发
console.dir(arguments);
},
onSelect: function (fileObj) { // 当每一个选中的文件添加到上传队列时触发
console.dir(arguments);
},
onSelectError: function (file, errorCode, errorMsg) { // 当每一个选中的文件添加到上传队列报错时触发
console.dir(arguments);
},
onSWFReady: function () { // 当swf加载完毕和准备就绪时触发
console.log("swf已初始化!");
},
onUploadComplete: function (fileObj) { // 当队列中每一个文件上传操作执行完成时触发,不管上传成功还是失败
console.dir(arguments);
},
onUploadError: function (fileObj, errorCode, errorMsg, errorString) { // 当队列中每一个文件上传失败时 触发
console.dir(arguments);
},
onUploadProgress: function (fileObj, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) { // 队列中每一个文件上传进度事件
console.dir(arguments);
},
onUploadStart: function (fileObj) { // 当队列中每一个文件上传开始时触发
console.dir(arguments);
},
onUploadSuccess: function (fileObj, data, response) { // 当队列中每一个文件上传成功时触发
console.dir(arguments);
}
});
/**
*方法
*/
//$('#file-upload').uploadify('cancel'); // 从队列中移出第一
//$('#file-upload').uploadify('cancel', "*"); // 清空队列
//$('#file-upload').uploadify('destroy'); // 销毁
//$('#file-upload').uploadify('disable', true); // 禁用|开启
//$('#file-upload').uploadify('setting', "name", "value"); // 设置|获取uploadify配置
//$('#file-upload').uploadify('stop'); // 停止
//$('#file-upload').uploadify('upload') // 启动上传
});
</script>
</head>
<body>
<input type="file" name="fileName" id="file-upload" />
</body>
</html>

后台程序与webconfig配置:

<system.web>
<httpRuntime executionTimeout="300" maxRequestLength="10240" /> <!--限制最大10MB-->
</system.web>
public class HomeController : Controller
{
[HttpPost]
public ActionResult UploadFile()
{
HttpPostedFileBase postedFile = Request.Files["uploadFileName"]; // 上传文件名须一致
if (postedFile != null)
{
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format("{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmsss"), Path.GetExtension(postedFile.FileName)));
using (Stream streamReader = postedFile.InputStream)
{
byte[] buffer = new byte[];
using (FileStream streamWriter = new FileStream(filePath, FileMode.Create, FileAccess.Write))
{
int read = streamReader.Read(buffer, , buffer.Length);
while (read > )
{
streamWriter.Write(buffer, , buffer.Length);
read = streamReader.Read(buffer, , buffer.Length);
}
streamWriter.Flush();
streamWriter.Close();
streamWriter.Dispose();
streamReader.Flush();
streamReader.Close();
streamReader.Dispose();
return Content("");
}
}
}
return Content("");
}
}

jquery.uploadify上传文件配置详解(asp.net mvc)的更多相关文章

  1. Uploadify 上传文件插件详解

    Uploadify 上传文件插件详解 Uploadify是JQuery的一个上传插件,实现的效果非常不错,带进度显示.不过官方提供的实例时php版本的,本文将详细介绍Uploadify在Aspnet中 ...

  2. [Plugin] JQuery.uploadify上传文件插件的使用详解For ASP.NET

    URL:http://www.cnblogs.com/xiaopin/archive/2010/01/21/1653523.html 今天下午整理文件上传的例子,感觉收集到的例子都很不人性话,后来找到 ...

  3. SpringMVC+jquery.uploadify 上传文件

    前言 以前用Asp.net MVC+uploadify上传文件,最近学习SpringMVC,所以就用SpringMVC+uploadify做个上传文件的demo. 刚开始用form表单的方式提交,在C ...

  4. MVC3+jquery Uploadify 上传文件

    最近做项目用到了上传图片的功能,以前也写过这类代码,不过都是用传统的file标签,今天整理一个好用的插件Uploadify..都做了一些注释,一看便知. 可以去官网下载最新的:Uploadify下载地 ...

  5. jquery uploadify上传文件插件导致浏览器崩溃问题解决方法

    自谷歌浏览器更新到(版本39.0.2171.99 )后,访问上传文件界面浏览器就崩溃了,而其他的浏览器不会出现问题. 出现这种问题的原因就是谷歌浏览器缓存问题,但将访问该jsp页面路径添加上时间戳后无 ...

  6. Django session cookie 上传文件、详解

    session 在这里先说session 配置URL from django.conf.urls import patterns, include, url from django.contrib i ...

  7. 通过`RestTemplate`上传文件(InputStreamResource详解)

    通过RestTemplate上传文件 1.上传文件File 碰到一个需求,在代码中通过HTTP方式做一个验证的请求,请求的参数包含了文件类型.想想其实很简单,直接使用定义好的MultiValueMap ...

  8. 使用jquery.uploadify上传文件

    今天在网上找了一天,想要找到一个比较全的使用案例,结果发现基本上全是一个版本的... 我的问题主要是上传完成后,还需要将路径获取到,然后保存到数据库. 查了一下资料发现有这么一个参数onComplet ...

  9. jQuery uploadify上传文件404,500错误

    1.如果部署到了IIS7的话,IIS7默认的大小为3000000.修改方法如下: 找到网站双击“请求筛选”——右边找到“编辑功能设置”——将“允许的最大内容长度”改成你想要的就行了. 2.当上传大文件 ...

随机推荐

  1. iOS开发系列--C语言之指针

    概览 指针是C语言的精髓,但是很多初学者往往对于指针的概念并不深刻,以至于学完之后随着时间的推移越来越模糊,感觉指针难以掌握,本文通过简单的例子试图将指针解释清楚,今天的重点有几个方面: 什么是指针 ...

  2. Btree 索引

    Btree 索引 索引是帮助数据库高效获取数据的一种数据结构,通过提取句子主干,就可以得到索引的本质. m-way查找树 如果想了解Btree,需要首先了解m-way数据结构. m-way查找树是是一 ...

  3. dofile执行ANDROID APK里面的文件

    我使用dofile执行APK文件是不行的,比如 dofile("assets/res/flist")只能先拷贝到writablePath然后再dofile拿到数据后再清除这个临时文 ...

  4. 如何给CentOS安装字体库

    很多时候,我们需要做一些图像生成工作(譬如验证码之类的),这时候,我们一般都需要用到系统的字体库.但事情却总非尽善人意,我们所使用的Linux操作系统无法像Windows操作系统那样足够“旗舰”,字体 ...

  5. 谷歌chrome浏览器www.tradeadexchange.com广告弹窗跳转劫持病毒

    近期大量网友出现chrome浏览器被劫持的情况,表现如下:           ·  点击(访问)任意网站任意链接均有概率弹出www.tradeadexchange.com.           ·  ...

  6. Java批处理ExecutorService/CompletionService

    服务端接收一个请求,常常需要同时进行几个计算或者向其他服务发送请求,最后拼装结果返回上游.本文就来看下JDK提供几个并行处理方案,牵涉到ExcecutorService/CompletionServi ...

  7. C# Azure 存储-分布式缓存Redis工具类 RedisHelper

    using System; using System.Collections.Generic; using Newtonsoft.Json; using StackExchange.Redis; na ...

  8. Java抽象类的总结

    什么是抽象类: 当你在定义一个父级的类的时候,往往在父级内的方法没有添加任何内容,这时候如果你在子类里面调用父级的时候,万一在子类之中类名或者方法名没有写正确,会出现不执行的情况,但是这种情况默认是不 ...

  9. iOS开发——高级技术&本地化与国际化详解

    本地化与国际化详解 效果如下:   英语:                                                                    中文: 具体实现如下: ...

  10. datagrid界面,链接数据库读取数据

    1.学生列表的 HTML部分 <script type="text/javascript"> $(function(){ //创建dataGrid $("#d ...