I’m saving file paths in database. Suppose an image file path, which is out of the project source folder. Collecting this path with the FileUpload Control. Next, reading this path from database into string like
string path=@dr["image"].ToString();
Now wanna show this image with the html image tag.
new_main.InnerHtml = "<a href=\"" + linkimage + "\"><img src=\"" + path + "\" alt=\"image\" /> </a>";
It’s not working. Checked in net,but nothing is working for me yet.Any idea about solution? Thanks in advance.
You need to use the relative path instead of using physical path.suppose you have hosted website in d:\Websites\Testsite\ then it is physical path and you access it by giving url
http://yourdomain/Testsite/first.htmlthen this is virtual path you have to give linkimage and path a virtual path.You can access the files within the website folder or you can make virtual directory of folders outside you website folder and access it through virtual directory. This article explains you have to make a virtual directory
Suppose you have website folder d:\websites\Testsite and you want to access files within d:\Data\Testfile.jpg, make a virtual directory in side TestWebsite pointing to d:\Data and access files within it through virual directory.