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=& ...
随机推荐
- 不通用版(从SVN取版本,通过MAVEN生成JAVA包,通过SALTSTACK传送到远程服务器并自动重启TOMCAT服务)PYTHON代码
从昨晚写到今天啊, 第一版测试成功了. PHP和JAVA的更新相对来说,PHP的自动化更新是简单多啦~~ 当然,这只是运维工作当中的一环~~ #!/usr/bin/env python # -*- c ...
- EMV规范 ---ISO7816 T=0协议的时间特性
复位应答期间: 字符间的时间间隔最小是12etu,最大是9600etu,但整个ATR不得超过19200etu(TS的起始沿到最后一个字符的起始沿 从卡片发出的连续字符其最小时间间隔为12etu,但是终 ...
- HDOJ(HDU) 2061 Treasure the new start, freshmen!(水题、)
Problem Description background: A new semester comes , and the HDU also meets its 50th birthday. No ...
- R学习日记——分解时间序列(非季节性数据)
分解时间序列,就是将一个时间序列拆分成不同的构成元件.一般序列(非季节性序列)包含一个趋势部分和一个不规则部分(也就是随机部分),而如果是一个季节性序列,除以上两个外,还有季节性部分. 在此,我们 ...
- c31 rotc_百度百科
c31 rotc_百度百科 c31 rotc
- C# 关键字--using
using 关键字有两个主要用途: (一).作为指令,用于为命名空间创建别名或导入其他命名空间中定义的类型. (二).作为语句,用于定义一个范围,在此范围的末尾将释放对象. using指令 ...
- POJ3273:Monthly Expense(二分)
Description Farmer John is an astounding accounting wizard and has realized he might run out of mone ...
- 【.NET跨平台】mac上安装VS for mac步骤详解
安装过程中提示以下内容 提示原文如下 It was not possible to complete an automatic installation. This might be due to a ...
- [Falcor] Intro to JSON Graph
JSON is a very commonly used data interchange format. Unfortunately while most application domain mo ...
- 不相交集python实现
1.不相交集是解决等价关系的一种数据结构,执行合并和查找的速度都很快,M次执行合并和查找的执行时间为(M*logN). 在一个集合中.对于每一对元素(a,b),a,b∈S,对于关系R假设满足以下三个条 ...