?? default.aspx.cs
字號:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Upload
{
/// <summary>
/// 上傳測試頁面
/// </summary>
public class _Default : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnUpload;
protected System.Web.UI.HtmlControls.HtmlInputFile uploadFile;
private void Page_Load(object sender, System.EventArgs e)
{
// 使用UploadID來唯一標識是當前的上傳
//
if (Request.QueryString["UploadID"] == null)
Response.Redirect("Default.aspx?UploadID=" + Guid.NewGuid().ToString());
// 當提交的時候,開始加載進度條
//
btnUpload.Attributes.Add("onclick", "window.setTimeout('LoadProgressInfo()', 500)");
}
#region Web 窗體設計器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調用是 ASP.NET Web 窗體設計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.btnUpload.Click += new System.EventHandler(this.btnUpload_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void uploadButton_ServerClick(object sender, System.EventArgs e)
{
}
private void btnUpload_Click(object sender, System.EventArgs e)
{
// 后端處理方法和普通的上傳是一樣的
//
string filename = this.uploadFile.PostedFile.FileName;
filename = filename.Substring(filename.LastIndexOf("\\"));
string FullPath=Server.MapPath("") + filename;
this.uploadFile.PostedFile.SaveAs(FullPath);
Response.Write("上傳文件:" + filename);
// 上傳完后使用腳本通知前端進度條
//
Response.Write("<script>parent.pb.UploadComplete();parent.ClearTimer();</script>");
Response.End();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -