jquery上传控件个人使用
转了一篇jquery的上传控件使用博文,但是,经过测试貌似不行,自己研究了一下,效果实现。记下,以后使用。
下载“Uploadify”,官方版本为php的,很多文件不需要,删除带.php的文件。
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="js/jquery-1.4.1.min.js"></script>
<link href="js/uploadify/uploadify.css" type="text/css" rel="Stylesheet"/>
<script type="text/javascript" src="js/uploadify/jquery.uploadify.js"></script>
<script type="text/javascript" src="js/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript">
$(function () {
$("#uploadify").uploadify({
'buttonClass': 'button',
'height': '20',
'width':'30',
'swf': './js/uploadify/uploadify.swf',
'cancelImg': './js/uploadify/uploadify-cancel.png',
'folder': './upload',
'buttonText': '上传',
'uploader': './UpLoadHandler.ashx',
'queueID': 'd',
'auto': 'true',
'multi': true,
'fileTypeDesc': 'Wrod文档(*.doc,*.docx)|Excel文件(*.xls,*.xlsx)|图片文件(*.jpg;*.png;*.gif;*.bmp;*.jpeg;*.tiff;*.dwg)|压缩文件(*.zip;*.rar;*.7z)',
'fileTypeExts': '*.doc;*.docx|*.xls,*.xlsx|*.jpg;*.png;*.gif;*.bmp;*.jpeg;*.tiff;*.dwg|*.zip;*.rar;*.7z',
'onUploadSuccess': function (file, data, response) {
if (data.indexOf('错误提示') > -1) {
alert(data);
}
else {
alert("上传成功!");
}
},
'onUploadError': function (file, errorCode, errorMsg, errorString) {
alert('文件:' + file.name + ' 上传失败: ' + errorString);
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="d"></div>
<input type="file" id="uploadify" name="uploadify" />
</div>
</form>
</body>
</html>
后台代码:
在一般处理程序里
public class UpLoadHandler : IHttpHandler,System.Web.SessionState.IRequiresSessionState{
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Charset = "utf-8";
string uploadPath = HttpContext.Current.Server.MapPath(@context.Request["folder"]) + "\\";
HttpPostedFile file = context.Request.Files["Filedata"];
if (file != null)
{
if (!System.IO.Directory.Exists(uploadPath))
{
System.IO.Directory.CreateDirectory(uploadPath);
}
context.Session["FilePath"] = uploadPath + file.FileName;//将上传文件路径保存到session 用于跨页传递
file.SaveAs(uploadPath + file.FileName);
}
//context.Response.Write("Hello World");
}
public bool IsReusable {
get {
return false;
}
}
}
jquery上传控件个人使用的更多相关文章
- JQuery上传控件 jUploader 使用
jUploader 1.0 Demo Download: jquery.jUploader-1.01.js 9.75kb Download: jquery.jUploader-1.01.min.js ...
- jquery上传控件uploadify使用备忘
我简单修改了js和样式,效果如下 使用起来也是超简单,将文件下载并解压到你网站目录下,然后 .在使用位置插入代码 ============================= <iframe wi ...
- jquery本地上传预览扩展(隐藏上传控件单击图片上传支持ie!!)
我用到的原材料地址:http://www.cnblogs.com/leejersey/p/3660202.html 修改后: /// <reference path="../../Js ...
- jquery文件上传控件 Uploadify
(转自 http://www.cnblogs.com/mofish/archive/2012/11/30/2796698.html) 基于jquery的文件上传控件,支持ajax无刷新上传,多个文件同 ...
- 用jQuery File Upload做的上传控件demo,支持同页面多个上传按钮
需求 有这么一个需求,一个form有多个文件要上传,但又不是传统的图片批量上传那种,是类似下图这种需求,一开始是用的swfupload做的上传,但是问题是如果有多个按钮的话,就要写很多重复的代码,于为 ...
- jquery文件上传控件 Uploadify 问题记录
Uploadify v3.2.1 首先引用下面的文件 <!--上传控件 uploadify--> <script type="text/javascript" s ...
- jquery文件上传控件 Uploadify 可以和ajax交互
http://www.cnblogs.com/mofish/archive/2012/11/30/2796698.html 原网址 基于jquery的文件上传控件,支持ajax无刷新上传,多个文件同 ...
- jquery文件上传控件 Uploadify(转)
原文:http://www.cnblogs.com/mofish/archive/2012/11/30/2796698.html 基于jquery的文件上传控件,支持ajax无刷新上传,多个文件同时上 ...
- 百度 flash html5自切换 多文件异步上传控件webuploader基本用法
双核浏览器下在chrome内核中使用uploadify总有302问题,也不知道如何修复,之所以喜欢360浏览器是因为帮客户控制渲染内核: 若页面需默认用极速核,增加标签:<meta name=& ...
随机推荐
- Github上最受关注的前端大牛,快来膜拜吧!
1. Paul Irish Github主页: https://github.com/paulirish 个人主页: http://paulirish.com 维基百科: http://en.wiki ...
- ajax vs oauth
http://www.cnblogs.com/rush/archive/2012/05/15/2502264.html https://www.ibm.com/developerworks/cn/xm ...
- stdout 与 stderr 的区别
stdout 与 stderr 的区别 一直没有注意 stdout 与 stderr 的区别,以为只是不同的描述方式.看来不是这样的. stdout 主要处理的是使用者输出 stderr 主要处理的错 ...
- Java 设计模式实现 不错的引用
这段时间有兴趣重新温习一下设计模式在Java中的实现,碰巧看到一个不错的设计模式总结,这里引用一下作为参考. 创建型模式: JAVA设计模式-Singleton JAVA设计模式-Factory JA ...
- openStack Use Orchestration module(heat) create and manage cloud resources
- 金洪林:红邦创衣止于至善_品牌-生活时尚_品牌_YOKA时尚网
金洪林:红邦创衣止于至善_品牌-生活时尚_品牌_YOKA时尚网 金洪林:红邦创衣止于至善
- 高性能JSON工具-FastJson处理超大JSON文本
使用阿里开源类库FastJson,当需要处理超大JSON文本时,需要Stream API,在fastjson-1.1.32版本中开始提供Stream API.文档参考GitHub:https://gi ...
- Mvc中DropDownList 和DropDownListFor的常用方法
Mvc中DropDownList 和DropDownListFor的常用方法 一.非强类型: Controller:ViewData["AreId"] = from a in rp ...
- node.js环境配置(angularjs高级程序设计中出现的错误)
一:npm install connect会出现错误:解决方法 1:$ npm install connect@2.X.X 2:$ npm install serve-static: 建立server ...
- Object-C变量作用域 -- 笔记
@interface Dog: NSObject { @public int age; @protected int ID; @Private float price; } @end 字段作用域解析: ...