zoukankan      html  css  js  c++  java
  • 多附件上传例子

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="uploadify.aspx.cs" Inherits="uploadify" %>
    
    <!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 runat="server">
        <title>uploadify用法</title>
         <link href="JS/jquery.uploadify-v2.1.0/example/css/default.css" rel="stylesheet"
            type="text/css" />
        <link href="JS/jquery.uploadify-v2.1.0/uploadify.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="JS/jquery.uploadify-v2.1.0/jquery-1.3.2.min.js"></script>
        <script type="text/javascript" src="JS/jquery.uploadify-v2.1.0/swfobject.js"></script>
        <script type="text/javascript" src="JS/jquery.uploadify-v2.1.0/jquery.uploadify.v2.1.0.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
    
                $("#uploadify").uploadify({
    
                    'uploader': 'JS/jquery.uploadify-v2.1.0/uploadify.swf',
                    'script': 'UploadHandler.ashx',
                    'scriptData': { billNum: $("#hdBillNum").val() },//传递的参数
                    'cancelImg': 'JS/jquery.uploadify-v2.1.0/cancel.png',
                    'folder': 'UploadFiles/store/',
                    'queueID': 'fileQueue',
                    'auto': false,
                    'multi': true, //多选
                    'width': '100',
                    'height': '27',
                    'buttonImg': 'JS/jquery.uploadify-v2.1.0/fj.gif',
                    'queueSizeLimit': 15, //允许上传的最大个数
                    'simUploadLimit': 15//同时上传的个数
                });
            });
    
      
            function Button1_onclick() {
                debugger;
                $('#uploadify').uploadifyUpload();
            }
    
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <input type="hidden" id="hdBillNum"  runat="server"/>
        <div>
         <table class="TableBorder" id="tabAttachment">
            <tr>
                <td align="right">
                    附件:
                </td>
                <td>
                    <input type="file" name="uploadify" id="uploadify" />
                </td>
            </tr>
            <tr>
                <td align="right">
                    &nbsp;
                </td>
                <td align="left">
                    <div id="fileQueue">
                    </div>
                  
                </td>
                <td>  <input id="Button1" type="button" value="上传附件"  onclick="return Button1_onclick()" /><br /></td>
            </tr>
             
        </table>
        </div>
        </form>
    </body>
    </html>

    上面是前台

    后台:

    一般处理程序uploadHander.ashx

    <%@ WebHandler Language="C#" Class="UploadHandler" %>
    
    using System;
    using System.Web;
    using System.IO;
    using System.Web.SessionState;
     
    using System.Data;
    
    
    public class UploadHandler : IHttpHandler, IReadOnlySessionState
    {
        
        public void ProcessRequest (HttpContext context) {
            context.Response.ContentType = "text/plain";
            context.Response.Charset = "utf-8";
    
         
            HttpPostedFile file = context.Request.Files["Filedata"];
            string uploadPath = HttpContext.Current.Server.MapPath(@context.Request["folder"]);//UploadFilespropertyManage
                
            if (file != null)
            {
                 
                //file.SaveAs(uploadPath + newFileName); //上传文件
                //sql="Insert into "//插入数据库            
                //context.Response.Write("1"); //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失 
            }
            else
            {
                context.Response.Write("0");
            }
        }
     
        public bool IsReusable {
            get {
                return false;
            }
        }
    
    }
    
  • 相关阅读:
    大数据量业务订制和解决方案思考
    gc内存回收机制
    HashMap的扩容机制, ConcurrentHashMap和Hashtable主要区别
    开源工作流引擎内核主要关心的是什么?
    mysql查询计划
    mysql 存储引擎MYSIAM和INNODB特性比较
    任意输入字符,对字符匹配进行判断
    java 对list中对象按属性排序
    mysql 写数据操作几次硬盘?
    win7_64位+U盘制作centos6.3+安装centos
  • 原文地址:https://www.cnblogs.com/zhaolijing910/p/3673724.html
Copyright © 2011-2022 走看看