Forums - C# Corner

Forum guidelines
Adalat  Khan

Adalat Khan

  • 883
  • 1.1k
  • 135.8k

Display Picture from the string path stored in DB in image

Feb 26 2019 2:02 AM
I want to display image in an image control using the string path stored in the database. The string path is retrieved successfully from the database but the image does not display. I tried my best but i did not success. Please help me in this regard. Thanks in advance. I tried the following:
 
Following is my HTML Code
 
<input type="image" id="img1" />
<input type="button" value="Display" onclick="DisplayPicture()" />
 
 
Following is my Javascript code
 
<script> 
function DisplayPicture()
{
var DisplayImage = document.getElementById("img1");
var path = "C:\Users\Adalat Khan\Dropbox\Personel\My Files\Pics\pic1.jpg";
DisplayImage.src = path.src;
DisplayImage.style.width = '160px';
DisplayImage.style.height = '135px';
}
 </script>
 
I used the above code just to check a single picture from a constant string path of an image but not success. Please correct my code. 

Answers (10)