我使用此代碼上傳圖像到server.YES其working.but我需要發送圖像路徑到我的數據庫。我有一個數據庫與配置文件表和ImagePath字段那裏。發送圖像路徑到數據庫
我怎樣才能做到這一點?
我的工作代碼是在這裏
public partial class ProfileDetails2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void upload_Click(object sender, EventArgs e)
{
int intFileSizeLimit = 10;
string strFileNameWithPath = FileUpload1.PostedFile.FileName;
string strExtensionName = System.IO.Path.GetExtension(strFileNameWithPath);
string strFileName = System.IO.Path.GetFileName(strFileNameWithPath);
int intFileSize = FileUpload1.PostedFile.ContentLength/1024;
strExtensionName = strExtensionName.ToLower();
if (strExtensionName.Equals(".jpg") || strExtensionName.Equals(".gif"))
{
if (intFileSize < intFileSizeLimit)
{
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/images/") + "img" + strExtensionName);
lblMessage.Text = "Uploaded file details <hr />" +
"File path on your Computer: " + strFileNameWithPath + "<br />" +
"File Name: " + strFileName + "<br />" +
"File Extension Name: " + strExtensionName + "<br />" +
"File Size: " + intFileSize.ToString();
}
else
{
lblMessage.Text = "File size exceeded than limit " + intFileSizeLimit + " KB, Please upload smaller file.";
}
}
else
{
lblMessage.Text = "Only .jpg or .gif file are allowed, try again!";
lblMessage.ForeColor = System.Drawing.Color.Red;
}
}
}
什麼,如果擴展名是「.JPG」? – usr