public void ProcessRequest(HttpContext context)
{
string esOIDs = System.Web.HttpContext.Current.Request["esOIDs"];
string userID=System.Web.HttpContext.Current.Session["USER_ID"].ToString(); context.Response.ContentType = "text/plain";
context.Response.Charset = "utf-8"; HttpPostedFile file = context.Request.Files["Filedata"];
string Path = HttpContext.Current.Server.MapPath(@context.Request["folder"]) + "\\AccessoryFiles"; if (!Directory.Exists(Path))//判断文件是否存在
{
Directory.CreateDirectory(Path);
} if (file != null)
{
if (file.ContentLength <= * * )//限定文件小于100M
{
bool fileOK = false;
string fileExtension = System.IO.Path.GetExtension(file.FileName).ToLower(); //得到选择文件 扩展名 string[] allowedExtensions = { ".doc", ".docx", ".ppt", ".pptx", ".xls", ".xlsx", ".pdf",".wmv",".avi", ".gif", ".png", ".bmp", ".jpg", ".mp4", ".rar", ".zip" }; //可上传文件类型列表
for (int i = ; i < allowedExtensions.LongLength; i++)//判断上传文件是否为上述合法类型
{
if (fileExtension == allowedExtensions[i])
{
fileOK = true;
break;
}
} if (fileOK == true)//如果文件格式正确
{
string uploadPath = Path + "\\" + esOIDs;
if (!Directory.Exists(uploadPath))//判断文件是否存在
{
Directory.CreateDirectory(uploadPath);
} string fileNewName = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName).ToLower();
file.SaveAs(uploadPath + "\\" + fileNewName); if (!Directory.Exists(uploadPath + "\\" + fileNewName))
{
AccessoryObj accessoryObj = new AccessoryObj();
accessoryObj.REFOID = esOIDs;
accessoryObj.ReftypeVal = AccessoryType.项目;
accessoryObj.FILENAME = file.FileName;
accessoryObj.FILETYPE = fileExtension;
accessoryObj.FILEPATH = "FileUpLoad/AccessoryFiles/" + esOIDs + "/" + fileNewName;
accessoryObj.UPLOADUSER = userID;
accessoryObj.UPLOADDATE = DateTime.Now; List<AccessoryObj> accList = new List<AccessoryObj>();
accList.Add(accessoryObj);
new AccessoryRepository().AddAccessoryObj(accList);
} //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
context.Response.Write("");
}
}
}
else
{
context.Response.Write("");
}
} public bool IsReusable
{
get
{
return false;
}
}

uploadhandler。ashx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FileUpLoad.aspx.cs" Inherits="FileUpLoad" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
//去网上download一个jquery uploadify插件 ,这些文件都有
<script src="../../Scripts/jquery/jquery.uploadify/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery/jquery.uploadify/jquery.uploadify.v2.1.0.min.js" type="text/javascript"></script> <script src="../../Scripts/jquery/jquery.uploadify/swfobject.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="../../Scripts/jquery/jquery.uploadify/uploadify.css" /> <script type="text/javascript">
$(document).ready(function () {
$("#uploadify").uploadify({
'uploader': '../../Scripts/jquery/jquery.uploadify/uploadify.swf',
'script': 'UploadHandler.ashx?esOIDs=<%=esOIDs %>',
'cancelImg': '../../Scripts/jquery/jquery.uploadify/cancel.png',
'folder': '../../FileUpLoad/',
'queueID': 'fileQueue',
'auto': false,
'multi': true,
'buttonText': '',
'fileDesc' :'可选择类型:.doc/.rar/.docx/.ppt/.pptx/.xls/.xlsx/.pdf/.gif/.png/.bmp/.jpg/.mp4/.rar/.wmv/.avi/.zip',
'fileExt': '*.doc;*.rar;*.docx;*.ppt;*.pptx;*.xls; *.xlsx;*.pdf;*.gif;*.png;*.bmp;*.jpg;*.mp4;*.rar;*.wmv;*.avi;*.zip', 'sizeLimit': * * ,
'buttonImg': '../../Scripts/jquery/jquery.uploadify/browse.png',
'height':'',
'width': ''
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="fileQueue" style="height: 400px"> </div>
<table>
<tr>
<td style="text-align: inherit">
<input type="file" name="uploadify" id="uploadify" onclick="return uploadify_onclick()" />
<input name="" onclick="javascript:$('#uploadify').uploadifyUpload()" type="button" style="height:20px" value="上传" />
<input name="" onclick="javascript:$('#uploadify').uploadifyClearQueue()" type="button" style="height:20px" value="取消上传" />
</td>
</tr>
</table>
</form>
</body> </html>

用jquery uploadify上传插件上传文件的更多相关文章

  1. 使用jQuery Uploadify在ASP.NET 上传附件

    Uploadify是JQuery的一个上传插件,实现的效果非常不错,带进度显示.Uploadify官方网址:http://www.uploadify.com/,在MVC中使用的方法可以参考 jQuer ...

  2. 在php中使用jquery uploadify进行多图片上传

    jquery uploadify是一款Ajax风格的批量图片上传插件,在PHP中使用jquery uploadify很方便,请按照本文介绍的方法和步骤,为你的PHP程序增加jquery uploadi ...

  3. [推荐]两款Flash上传插件(1)–CFUpdate文件批量上传组件

    搞开发的同学都知道,网上可搜到的可用的Flash图片上传的组件少之又少,可定制界面,不需要安装组件,且可免费用于任何商业系统的,更是凤毛麟角,如果你和我一样,迫切需要一款这样的一款组件的话,不妨试试C ...

  4. webuploader 文件上传插件 IE8/9 文件选择不上传

    IE8/9下文件上传是采用flash模式,一直发送http://xxx.xxx.xx.xx:8888/crossdomain.xml请求,状态码为404,原因是上传文件的服务器未配置crossdoma ...

  5. jQuery上传插件Uploadify使用帮助

    Uploadify是JQuery的一个上传插件,实现的效果非常不错,带进度显示.它的功能特色总结如下: 支持单文件或多文件上传,可控制并发上传的文件数 在服务器端支持各种语言与之配合使用,诸如PHP, ...

  6. jQuery上传插件Uploadify使用介绍

    以图纸资料上传为例,介绍Uploadify插件的使用,插件下载地址   http://www.uploadify.com/download/ 上传页面: 选择文件增加未上传界面: 上传成功预览界面: ...

  7. 网站开发常用jQuery插件总结(15)上传插件blueimp

    在介绍这个插件之前,先吐槽一下.这个插件功能很强大.带有的功能有:上传(单个文件或批量文件),自动上传或点击按钮上传,上传前缩略图显示,判断文件格式,上传前的文件操作,上传时进度条显示等功能.如果你用 ...

  8. FCKeditor插件开发实例:uploadify多文件上传插件

    FCKeditor是一个专门使用在网页上属于开放源代码的所见即所得文字编辑器.它志于轻量化,不需要太复杂的安装步骤即可使用.它可和PHP.JavaScript.ASP.ASP.NET.ColdFusi ...

  9. 可拖拽和带预览图的jQuery文件上传插件ssi-uploader

    插件描述:ssi-uploader是一款带预览图并且可以拖拽文件的jQuery ajax文件上传插件.该文件上传插件支持AJAX,支持多文件上传,可控制上的文件格式和文件大小,提供各种回调函数,使用非 ...

随机推荐

  1. Mysql Atm取款机系统模拟案例

    #创建ATM数据库 CREATE DATABASE ATM; #创建用户CREATE USER `ATMMaster` IDENTIFIED BY '1234';GRANT ALL ON ATM.* ...

  2. spring与mybatis整合(扫描Mapper接口)

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean" ...

  3. windows server 2008 R2中建立ftp站点

    在windows server 2008 R2中建立ftp站点,要遵循以下步骤: (1) 开启IIS中的ftp服务: (2) 在IIS中建立ftp站点. 具体过程如下: (1) 开启IIS中的ftp服 ...

  4. 记录用友T+接口对接的心酸历程

    前言:公司的业务主要是对接财务系统做单据传输或者凭证处理的,难免少不了和各大财务软件做数据对接,其中当然是必须通过接口来传递数据了.于是乎,用友T+的版本来了,对接的工作自然是我来做,可没想到就是这样 ...

  5. 【Java例题】2.2 分数类

    2.定义分数类,包括分子和分母变量.构造方法. 加减乘除方法.化简方法.值计算方法和显示分子和分母的方法. 然后编写一个主类,在其主方法中通过定义两个分数对象来 显示每一个分数的分子值.分母值.化简和 ...

  6. QT动画时间轴控制 QTimeLine

    QTimeLine类提供用于控制动画的时间轴 比如控制进度条的增长,图片,窗口的旋转,平移等等 QTimeLine有一个frameChanged(int)信号 当调用QTimeLine::start( ...

  7. python调用支付宝支付接口

    python调用支付宝支付接口详细示例—附带Django demo代码   项目演示: 一.输入金额 二.跳转到支付宝付款 三.支付成功 四.跳转回自己网站 在使用支付宝接口的前期准备: 1.支付宝公 ...

  8. react中babel的使用

    在开发中经常会使用到es6语法,那么如何能够很好兼容es6写法呢

  9. JVM(十二):方法调用

    JVM(十二):方法调用 在 JVM(七):JVM内存结构 中,我们说到了方法执行在何种内存结构上执行:Java 方法活动在虚拟机栈中的栈帧上,栈帧的具体结构在内存结构中已经详细讲解过了,下面就让我们 ...

  10. springboot启动慢解决方法

    jdk的配置文件中,使用securerandom.source设置了熵源: cat /usr/java/jdk1.8.0_121/jre/lib/security/java.security secu ...