?? up_loadcs.cs
字號:
using System;
using System.IO;
namespace sp
{
/// <summary>
/// Up_Loadcs 的摘要說明。
/// </summary>
public class Up_Loadcs
{
public string Up(System.Web.UI.HtmlControls.HtmlInputFile File2)
{
//
// TODO: 在此處添加構(gòu)造函數(shù)邏輯
//
if (File2.PostedFile.ContentLength.ToString() == "0")
{
return "上傳失敗或指定的文件不存在";
}
else
{
//獲取文件名稱
string ss ;
ss =System.DateTime.Now.ToString().Replace("-","").Replace(" ","").Replace(":","")+Path.GetExtension(File2.PostedFile.FileName);
if (File2.PostedFile.ContentLength/1024>10240)
{return "您的文件過大,不能上傳!";}
else
{
string ty=File2.PostedFile.ContentType;
if (ty=="image/gif"||ty=="image/pjpeg")
{
File2.PostedFile.SaveAs(System.Web.HttpContext.Current.Server.MapPath("Uploads/") + ss);
return ss;
//Up= ss;
}
else
{return "限制上傳!";}
}
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -