我有下面的C#代碼:重命名上傳的文件名C#
SelectQuery = string.Format("SELECT UserID from tblUsers WHERE Email='{0}'", Email);
ds = DbQ.ExecuteQuery("SiteDB.mdb", SelectQuery);
string UserID = ds.Tables[0].Rows[0]["UserID"].ToString();
if (Request.ContentLength != 0)
{
int Size = Request.Files[0].ContentLength/1024;
if (Size <= 512)
{
string LocalFile = Request.Files[0].FileName;
int LastIndex = LocalFile.LastIndexOf(@"\") + 1;
File = LocalFile.Substring(LastIndex, LocalFile.Length - LastIndex);
// File = "ProfilePic-Id-" + UserID;
string Path = Server.MapPath("images/profiles/") + File;
Request.Files[0].SaveAs(Path);
}
else
{
Response.Write("The file is too big !");
}
}
else
{
Response.Write("Unknown Error !");
}
我想的是,上傳的文件名重命名爲「ProfilePic-ID-」 +用戶ID,我試圖在發表評論,但它沒不工作,我如何重命名上傳的文件名?
希望得到幫助,謝謝!
的SQL注入概率... –
'但它沒有工作...' - 什麼** **沒有發生? –
我的電子郵件是''; DROP TABLE向tblUsers;' –