关于数据库保存上传文件路径问题-高分在线
我已经把文件上传到文件夹里files了:
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string FileName = FileUpload1.FileName;
string strExPrentFile = FileName.Substring(FileName.LastIndexOf(".") + 1);
string[] NoExPrentFile = new string[] { "exe", "asp", "php" };
bool IsUp = true;
for (int i = 0; i < NoExPrentFile.Length; i++)
{
if (strExPrentFile.Equals(NoExPrentFile[i]))
{
IsUp = false;
}
}
if (IsUp)
{
string sFilePath = string.Format("files/{0}.{1}", DateTime.Now.ToString("mmhhddss"), strExPrentFile);
FileUpload1.SaveAs(Server.MapPath(sFilePath));
this.Label1.Text = "文件上传成功!" + "<br />文件名是:" + string.Format("{0}.{1}", DateTime.Now.ToString("mmhhddss"), strExPrentFile) + "<br />文件的格式:" + strExPrentFile;
}
else
{
this.Label1.Text = string.Format("不允许上传{0}格式文件", NoExPrentFile);
}
}
else
{
this.Label1.Text = "不能上传空文件";
}
}
}
但我不知道怎么在数据库中保存上传文件的路径---怎么写代码呢。。要求详细。不能乱说。
数据库要写什么存储过程么