本文实例为大家分享了asp.net uploadify多附件上传的方法,供大家参考,具体内容如下
1、说明
uploadify是一款优秀jQuery插件,主要功能是批量上传文件。大多数同学对多附件上传感到棘手,现将asp.net结合uploadfiy如何实现批量上传附件给大家讲解一下,有什么不对的地方还请大家多多交流沟通,下面把代码贴出来大家一起交流。
2、组成
首先说明一下代码实现所用到的技术,仅供参考:
开发工具:vs2010
目标框架:.NET Framework3.5
Uploadify:uploadify-v3.1
Jquery:jquery-1.8.1.js
最后我会将整个Demo上传,如果同学们的电脑上有开发环境可直接打开项目解决方案运行。
3、代码
Default.aspx(测试页面)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="FileUpload._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://plete : function(file,swfuploadifyQueue) {//队列中的每个文件上传完成时触发一次 alert( 'id: ' + file.id + ' - 索引: ' + file.index + ' - 文件名: ' + file.name + ' - 文件大小: ' + file.size + ' - 类型: ' + file.type + ' - 创建日期: ' + file.creationdate + ' - 修改日期: ' + file.modificationdate + ' - 文件状态: ' + file.filestatus + ' - 出错的文件数: ' + swfuploadifyQueue.filesErrored + ' - 错误信息: ' + swfuploadifyQueue.errorMsg + ' - 要添加至队列的数量: ' + swfuploadifyQueue.filesSelected + ' - 添加至对立的数量: ' + swfuploadifyQueue.filesQueued + ' - 队列长度: ' + swfuploadifyQueue.queueLength);} onUploadError : function(file,errorCode,errorMsg,errorString,swfuploadifyQueue) {//上传文件出错是触发(每个出错文件触发一次) alert( 'id: ' + file.id + ' - 索引: ' + file.index + ' - 文件名: ' + file.name + ' - 文件大小: ' + file.size + ' - 类型: ' + file.type + ' - 创建日期: ' + file.creationdate + ' - 修改日期: ' + file.modificationdate + ' - 文件状态: ' + file.filestatus + ' - 错误代码: ' + errorCode + ' - 错误描述: ' + errorMsg + ' - 简要错误描述: ' + errorString + ' - 出错的文件数: ' + swfuploadifyQueue.filesErrored + ' - 错误信息: ' + swfuploadifyQueue.errorMsg + ' - 要添加至队列的数量: ' + swfuploadifyQueue.filesSelected + ' - 添加至对立的数量: ' + swfuploadifyQueue.filesQueued + ' - 队列长度: ' + swfuploadifyQueue.queueLength);} onUploadProgress : function(file,fileBytesLoaded,fileTotalBytes,queueBytesLoaded,swfuploadifyQueueUploadSize) {//上传进度发生变更时触发alert( 'id: ' + file.id + ' - 索引: ' + file.index + ' - 文件名: ' + file.name + ' - 文件大小: ' + file.size + ' - 类型: ' + file.type + ' - 创建日期: ' + file.creationdate + ' - 修改日期: ' + file.modificationdate + ' - 文件状态: ' + file.filestatus + ' - 当前文件已上传: ' + fileBytesLoaded + ' - 当前文件大小: ' + fileTotalBytes + ' - 队列已上传: ' + queueBytesLoaded + ' - 队列大小: ' + swfuploadifyQueueUploadSize);} onUploadStart: function(file) {//上传开始时触发(每个文件触发一次) alert( 'id: ' + file.id + ' - 索引: ' + file.index + ' - 文件名: ' + file.name + ' - 文件大小: ' + file.size + ' - 类型: ' + file.type + ' - 创建日期: ' + file.creationdate + ' - 修改日期: ' + file.modificationdate + ' - 文件状态: ' + file.filestatus );} onUploadSuccess : function(file,data,response) {//上传完成时触发(每个文件触发一次) alert( 'id: ' + file.id + ' - 索引: ' + file.index + ' - 文件名: ' + file.name + ' - 文件大小: ' + file.size + ' - 类型: ' + file.type + ' - 创建日期: ' + file.creationdate + ' - 修改日期: ' + file.modificationdate + ' - 文件状态: ' + file.filestatus + ' - 服务器端消息: ' + data + ' - 是否上传成功: ' + response); }5、最后奉上Demo:FileUpload
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。