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. JNDI资源(一)

    JNDI:Java命名与目录接口 是一个应用程序设计的API,为开发人员提供了查找和访问各种命名和目录的通用.统一的服务. 使用JNDA的步骤: 1.配置资源. //Tomcat跟目录/conf/co ...

  2. (读论文)推荐系统之ctr预估-NFM模型解析

    本系列的第六篇,一起读论文~ 本人才疏学浅,不足之处欢迎大家指出和交流. 今天要分享的是另一个Deep模型NFM(串行结构).NFM也是用FM+DNN来对问题建模的,相比于之前提到的Wide& ...

  3. vscode vue开发环境搭建

    以前仅了解过VUE但没有真正上手过,现在因为工作需要准备再近几个月里系统的学习一下这款超火的前端框架,希望大佬们指教. ---------------------------------------- ...

  4. 深入学习 Intellij IDEA 调试技巧

    程序员的日常工作除了写代码之外,很大一部分时间将会在查找 BUG,解决问题.查找 BUG,离不开在 IDE 中调试代码.熟练的掌握调试技巧,可以帮助我们减少查找时间,快速定位问题. 在 IDEA 中调 ...

  5. 【iOS】更换证书遇到的问题

    今天给一个项目换证书的时候遇到了这个问题: Code Sign error: Provisioning profile does not match bundle identifier: The pr ...

  6. SpringBoot的yml配置

    Spring Boot的yml配置 #开发配置 spring: data: solr: host: http://localhost:6789/solr/mote mvc: view: # 页面默认前 ...

  7. .net持续集成测试篇之Nunit常见断言

    系列目录 Nunit测试基础之简单断言 在开始本篇之前需要补充一些内容,通过前面搭建Nunit测试环境我们知道要使一个方法成为单元测试方法首先要在此方法所在类加上TestFixture注解,并且在该方 ...

  8. 7z 命令行方式生成自解压exe

    一.下载 7z是一个免费的工具,除了通过命令行的方式提供各种文件.压缩包相关的操作外,还提供了一种方式可以打出自解压的exe程序.该程序从运行到结束经历了三个流程: (1) 解压文件到用户临时目录: ...

  9. 有趣的Flex布局

    对于刚接触前端的小白,在还原页面样式的时候,往往会遇到页面布局(layout)上的问题,用着生硬的padding来固定盒子的位置,不仅代码看的沉重,还得适应各种浏览器页面,始终没有办法做到统一.接下来 ...

  10. umask 默认权限控制和特殊权限

    权限简单介绍: 在Linux中,创建目录或者文件之后总会有默认的权限.共9个,分为三组.分别代表u.g.o(属主.属组.其他用户).r.w.x 也代表各自的权限. r:读   在文件中的权限代表次文件 ...