周一的工作 张孝祖 11.5日

今天把函数在进一步修改,提供了错误提醒,积分加减等功能,界面还需要进一步的设计,但功能都已实现,

明天需要找个人测试一下各种违规上传的情况,看看能不能一直稳定运行。反正我自己测试还是可以稳定上传的。

代码如下

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial class upload : System.Web.UI.Page
{
   public string title = null;           //标题
   public string keyWord = null;         //关键词
   public string author = null;          //作者
   public string filetype = null;        //类型
    protected void Page_Load(object sender, EventArgs e)
    {

       
    }//初始化页面
    protected void OK_Click(object sender, EventArgs e)   //点击上传时
    {

        title = Title.Text;
        keyWord = Keyword.Text;
        author = Author.Text;
        filetype = Type.Text;
        int temp=0;
        temp = (int)Application["point"];
        if ((title=="")||(filetype==""))    
        {
            Response.Write("<script>alert('请填写必填项目');</script>");

        }
        else
        {
            if (fu.HasFile == true)
            {
                fu.SaveAs(MapPath(fu.FileName));
                temp++;
                Application["point"] = temp.ToString();
                Response.Redirect("UpLoadContent.aspx");
                Response.Write("<script>alert('上传完成,积分加1');</script>");

            }
            else
            {
                Response.Write("<script>alert('请选择上传文件');</script>");
            }
        }
      
    }
    
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="upload.aspx.cs" Inherits="upload" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <style type="text/css">
        .auto-style1
        {
            text-align: center;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="auto-style1">
        <asp:Label ID="Top" runat="server" Text="题目(必填)"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Label ID="Author1" runat="server" Text="作者"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Label ID="Type1" runat="server" Text="文件类型"></asp:Label>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Label ID="Keyword1" runat="server" Text="关键字"></asp:Label>
       
        <br />
        <asp:TextBox ID="Title" runat="server" Width="83px"></asp:TextBox>
&nbsp;
        <asp:TextBox ID="Author" runat="server" Width="98px"></asp:TextBox>
&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="Type" runat="server" Width="102px"></asp:TextBox>
&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="Keyword" runat="server" Width="102px"></asp:TextBox>
        <br />
        <br />
        <asp:FileUpload ID="fu" runat="server"/><br/>
        <asp:Button ID="btnSure" runat="server" OnClick="OK_Click" Text="上传文件到服务器">
        </asp:Button>
    </div>
    </form>
    <p>
        &nbsp;</p>
</body>
</html>
posted @ 2012-11-05 22:56  DOOM_buaascse  阅读(222)  评论(0编辑  收藏  举报