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. 程序员的长安十二时辰:Java实现从Google oauth2.0认证调用谷歌内部api

    最近公司在做一个app购买的功能,主要思路就是客户在app上购买套餐以后,Google自动推送消息到Java后端,然后Java后端通过订单的token获取订单信息,保存到数据库. Java后端要获取订 ...

  2. 初始SpringMVC 完整版

    初始SpringMVC 1.SpringMVC 也叫Spring Web mvc,属于表现层的框架.Spring MVC是Spring框架的一部分,是在Spring3.0后发布的. 2.Java EE ...

  3. [解决方案]IIS配置后报错404,500,502等系列问题

    很多时候刚部署完服务器的IIS以后,第一次部署站点都会出现形形色色,各种各样的报错问题,但这些问题大同小异,我这里就给大家提供的解决的方案,以达到以不变应万变的效果 目的:让大家学会处理类似问题的方法 ...

  4. PHP xdebug API接口优化揪出了getimagesize这个鬼

    在API优化list中,公司客户系统的服务号客服有个获取聊天消息的接口getHistory请求时间很长,就去优化了下,记下过程. 一,配置环境,追踪使用Xdebug: 1.在https://xdebu ...

  5. ProcessBuilder waitFor 调用外部应用

    小程序项目最初使用ffmpeg转换微信录音文件为wav格式,再交给阿里云asr识别成文字.视频音频转换最常用是ffmpeg. 1 ffmpeg -i a.mp3 b.wav 相关文章: 小程序实现语音 ...

  6. HashMap常见面试题整理

    花了三天时间来仔细阅读hashMap的源码,期间补了下不少数据结构的知识,刷了不少相关的面试题并进行了整理 1.谈一下HashMap的特性? 1.HashMap存储键值对实现快速存取,允许为null. ...

  7. 开启java之门

    一.Java语言概述 Java语言诞生于1995年,由Sun公司推出. 2009年,Sun公司被甲骨文公司收购,所以我们现在访问oracle官网即可:https://www.oracle.com Ja ...

  8. weblogic10.3.6漏洞修改方案

    1.CVE-2018-2628漏洞 CVE-2018-2628漏洞利用的第一步是与weblogic服务器开放在服务端口上的T3服务建立socket连接,可通过控制T3协议的访问来临时阻断攻击行为. W ...

  9. indexedDB添加,删除,获取,修改

    [toc] 在chrome(版本 70.0.3538.110)测试正常 编写涉及:css, html, js 在线演示codepen html代码 <h1>indexedDB</h1 ...

  10. pull解析案例

    此pull解析案例是eclipes的对不对,不知道, private void getXml() { try { InputStream is = getAssets().open("new ...