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

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!User.Identity.IsAuthenticated || Request.Cookies["12ymadmin"] == null || Request.Cookies["12ymadmin"]["key"] == null)
        {
            Response.End();
        }

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string fileDesc = "";
        Aspx1.UI.FileUpload.FileType = ".rar,.zip";
        Aspx1.UI.FileUpload.UploadPath = "/Upload/Source/";
        string downurl = Aspx1.UI.FileUpload.Save(out fileDesc);
        if(downurl.EndsWith("|"))
            downurl = downurl.Substring(0,downurl.Length-1);
        Response.Write("源码上传成功！");
        ClientScript.RegisterStartupScript(this.GetType(), "sdfas", "parent.document.getElementById('txtDownURL').value='" + downurl + "';", true);
    }
</script>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>要俩源码</title>
    <meta http-equiv="keywords" content="要俩源码" />
    <meta name="description" content="要俩源码" />

    <script language="javascript" type="text/javascript">
function checkExt(obj)
{
    var path = obj.value;
    var extensions = 'rar,zip';  
    var ext = path.lastIndexOf('.') == -1 ? '' : path.substr(path.lastIndexOf('.') + 1, path.length).toLowerCase();
    var re = new RegExp("(^|\\s|,)" + ext + "($|\\s|,)", "ig");
    if(path == '') 
    {
        return;
    } 
    if(extensions != '' && (re.exec(extensions) == null || ext == '')) 
    {
        obj.value ="";
        alert('对不起，不支持上传此类扩展名的附件。');
        return;
    }
}
    </script>

</head>
<body style="margin: 0px; font-size: 12px">
    <form name="form1" id="form1" runat="server" enctype="multipart/form-data">
    <input type="file" id="upfile" name="upfile" onchange="checkExt(this);" />&nbsp;&nbsp;<asp:Button
        ID="Button1" runat="server" Text=" 上 传 " OnClick="Button1_Click" />
    <br />
    目前只允许上传rar，zip两种扩展名的文件。
    </form>
</body>
</html>
