I am getting binary bytes from database and converting them into to png images and saving them in the /Images folder of the project and displaying them through tags. the files are created and used in the Developer environment but as soon as I publish it only the files are created in the images folder but it is not being read or being displayed in the IMG tag.
我从数据库获取二进制字节并将它们转换为png图像并将它们保存在项目的/ Images文件夹中并通过标签显示它们。这些文件是在Developer环境中创建和使用的,但是一旦我发布它,只有文件在images文件夹中创建,但它没有被读取或显示在IMG标签中。
public string Image_Binary(string pic_id)
{
var imagepath=ConfigurationManager.AppSettings["ImagePath"];
string picstring;
string pid = pic_id;
string path = imagepath+ pid + ".Png";
if (pid != null && pid != "")
{
if (File.Exists(Server.MapPath(path)))
{
picstring = imagepath + pid + ".Png";
}
else
{
DataSet picds = DB.fetchdata("select PictureBinary FROM Picture where Id=" + pic_id);
byte[] picbin = (byte[])picds.Tables[0].Rows[0][0];
ImageConverter ic = new ImageConverter();
System.Drawing.Image img = (System.Drawing.Image)ic.ConvertFrom(picbin);
img.Save(Server.MapPath(imagepath + pid + ".Png"), System.Drawing.Imaging.ImageFormat.Png);
picstring = imagepath + pid + ".Png";
}
}
else
{
//picstring = null;
picstring = "#";
}
return picstring;
}
Web.config entry
<appSettings>
<add key="ImagePath" value="~/ProductImages/"
</appSettings>
1 个解决方案
#1
if your images are not stored in the default Images folder then after publishing the new folder will not be included. its not the code fault. as much as i can see the code is correct. check your image path if the folder is created after build.
如果您的图像未存储在默认的图像文件夹中,则在发布后将不包括新文件夹。它不是代码错误。尽管我能看到代码是正确的。如果在构建后创建文件夹,请检查图像路径。
#1
if your images are not stored in the default Images folder then after publishing the new folder will not be included. its not the code fault. as much as i can see the code is correct. check your image path if the folder is created after build.
如果您的图像未存储在默认的图像文件夹中,则在发布后将不包括新文件夹。它不是代码错误。尽管我能看到代码是正确的。如果在构建后创建文件夹,请检查图像路径。