zoukankan      html  css  js  c++  java
  • Gmail式的上传

    原理参见
    http://www.cnblogs.com/xbf321/archive/2007/11/09/954317.html

    <%@ Page Language="C#" %>

    <!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>File Upload</title>
        
    <script type="text/javascript" src="js/jquery-1.2.6.js"></script>
        
    <script type="text/javascript">
        $(document).ready(
    function(){
            
    if(window.top == window)
            {
                
    var $div = $(document.createElement("div"));
                $div.html(
    "<iframe src='"+document.URL+"' name='uploadiframe' id='uploadiframe'></iframe>");
                $div.css({display:
    "none"})
                $(
    "body").append($div);
                $(
    "form").attr("target","uploadiframe");
                $(
    "form").submit();
                
                
                $(
    ".myupload").empty(); 
                
    var $a = $(document.createElement("a"));
                $($a).html(
    "upload");
                
                
                $($a).click(
    function(){
                    $(
    "#uploadiframe").contents().find(":file").click();
                    $(
    "#uploadiframe").contents().find(":submit").click();
                    
    return false;
                });
                
                $(
    ".myupload").append($a); 
            }
        });
        
    </script>
        
    <script type="text/C#" runat="server">
            protected 
    void File_Upload(object sender, EventArgs e)
            {
                
    if (FileUploadControl.HasFile == true)
                {
                    FileUploadControl.SaveAs(@
    "D:\upload\" + FileUploadControl.FileName);
                }
            }
        
    </script>
    </head>
    <body>
        
    <form id="form1" runat="server">
        
    <div class="myupload">
        
    <asp:FileUpload ID="FileUploadControl" runat="server" />
        
    <asp:Button runat="server" OnClick="File_Upload" Text="Upload It" />
        
    </div>
        
    </form>
    </body>
    </html>


     

  • 相关阅读:
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    如何在一个类中定义一些常量,每个对象都可以方便访问这些常量而不用重新构造?
    __init__函数一定需要吗
    python 面向对象编程
    Linux 操作系统原理 — mmap() 进程虚拟内存映射
    在VSCode中刷leetcode
    MIMO 天线技术
  • 原文地址:https://www.cnblogs.com/goodspeed/p/1257983.html
Copyright © 2011-2022 走看看