【发布时间】:2017-08-15 18:08:57
【问题描述】:
图像未从 asp.net 中的给定路径加载 这里,是情景。我已经使用 asp.net 将图像上传到文件夹并将其插入到 SQL 服务器数据库的路径,但是当我尝试从我的 asp 应用程序“路径正确”的路径中获取图像时,图像无法加载.没有错误。
这是上传数据的代码
if (FileUpload1.HasFile && TextArea1.Value != null)
{
string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
string path = Server.MapPath("/admin/images/" +fileName);
FileUpload1.PostedFile.SaveAs(Server.MapPath("/admin/images/" + fileName));
//Response.Write("<script>alert('" + path + "');</script>");
string ta1 = TextArea1.Value;
string sql = "UPDATE homep SET img = '" + path + "', description= '" + ta1.Replace("'", "''") + "' WHERE id = 1;";
cmd = new SqlCommand(sql, con);
if (cmd.ExecuteNonQuery() > 0)
{
Response.Write("<script>alert('Updation Success ..!');</script>");
}
}
这是获取数据的代码
dr.Read();
Response.Write("<img src='"+dr["img"].ToString()+"' class='img-responsive'/>");
dr.Close();
This Image shows final output as i am getting content but not getting image from path
【问题讨论】:
标签: c# asp.net sql-server asp.net-mvc asp.net-mvc-4