zoukankan      html  css  js  c++  java
  • Jquery plugin(多文件上传)

    前台代码:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

    <!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>无标题页</title>

        <script src="JQuery/jquery.js" type="text/javascript" language="javascript"></script>

        <script src="JQuery/jquery.MultiFile.js" type="text/javascript" language="javascript"></script>

    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <fieldset>
                <asp:FileUpload ID="FileUpload1" runat="server" class="multi"  maxlength="2" />
                <asp:Button ID="btnUpload" runat="server" Text="Button" onclick="btnUpload_Click" />
            </fieldset>
        </div>
        </form>
    </body>
    </html>
    后台代码:protected void btnUpload_Click(object sender, EventArgs e)
           {
               try
              
    {
                   HttpFileCollection hfc = Request.Files;
                   for (int i = 0; i < hfc.Count; i++)
                   {
                       HttpPostedFile hpf = hfc[i];
                       if (hpf.ContentLength > 0)
                       {
                           hpf.SaveAs(Server.MapPath("MyFile") + "\\"
                              
    + System.IO.Path.GetFileName(hpf.FileName));
                           Response.Write("<script>alert('文件上传成功!')</script>");
                       }
                   }
               }
               catch (Exception ex)
               {
                   throw ex;
               }
           }

    效果图:

    image

    Jquery plugin下载:/Files/ly5201314/multiple-file-upload.zip

    只需要引用两个js文件:jquery.js;jquery.MultiFile.js。class="multi"  maxlength="2" 是关键代码。

  • 相关阅读:
    报表打印
    MyGridControl
    用户控件制作时设计模式加载报错的解决办法
    代码生成工具
    上传控件的使用
    数据加密
    DevExpress介绍
    记一次手动安装pecl扩展memcache
    关于httpd.conf的一点随笔
    temp
  • 原文地址:https://www.cnblogs.com/ly5201314/p/1456611.html
Copyright © 2011-2022 走看看