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=& ...
随机推荐
- 【HDOJ】1506 Largest Rectangle in a Histogram
Twitter还是Amazon拿这个题目当过面试题.DP区间求面积. /* 1506 */ #include <cstdio> #include <cstring> #incl ...
- -_-#【Canvas】导出在<canvas>元素上绘制的图像
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- -_-#ueditor编辑器chrome浏览器下只能复制最后一行
被过滤掉了
- 【转】 Android 基于google Zxing实现对手机中的二维码进行扫描--不错
原文网址:http://blog.csdn.net/xiaanming/article/details/14450809 转载请注明出处:http://blog.csdn.net/xiaanming/ ...
- js打开新的链接下载文件
var p =params.join("&"); var a = document.createElement('a'); a.href = 'report/exportp ...
- AFNetworking (3.1.0) 源码解析 <二>
这次讲解AFHTTPSessionManager类,按照顺序还是先看.h文件,注释中写到AFHTTPSessionManager是AFURLSessionManager的子类,并且带有方便的HTTP请 ...
- Android 适配
给定字体大小适配时应按照12sp,14sp,18sp,22sp 这几种字体的大小设置,以避免字体大小混乱12sp以上大小,14sp 18sp 22sp 字体首选大小,不要使用奇数.小数,否则会造成精度 ...
- 对openflow 1.0协议的扩展
通过这几天对openvswitch代码的分析,以及项目的须要,须要对openflow 1.0进行一定的扩展,发现网上没有这方面的教程,尽管在搞懂ovs代码架构,floodlight controlle ...
- 各个函数消耗的时间profiling和内存泄漏valgrind
来源:http://06110120wxc.blog.163.com/blog/static/37788161201333112445844/ ARM(hisi)上面的profiling和valgri ...
- [转] 关于SIGPIPE导致的程序退出
PS: 如果服务器程序不忽略SIGPIPE,在某些时候TCP writer收到这个信号,会导致进程退出 The rule that applies is: When a process writes ...