直接用Sumbit按鈕提交
protected void Page_Load(object sender, EventArgs e)
{
string filePath = string.Empty;
if (IsPostBack)
{
string Path = Server.MapPath("upload/");//設(shè)置服務(wù)器端路徑
filePath = this.filepost.PostedFile.FileName;//獲取客戶端實(shí)際路徑
string fileName = filePath.Substring(filePath.LastIndexOf("\\") + 1);//獲取文件名稱
string serverPath = Path + fileName;//上傳的文件保存到服務(wù)器端的路徑
this.filepost.PostedFile.SaveAs(serverPath);
}
}
//如有更加復(fù)雜的邏輯可以繼續(xù)添加條件判斷
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點(diǎn)擊舉報。