Skip to content Skip to sidebar Skip to footer

How To Retrieve And Show Images From Another Drive Using Src Attribute In Tag?

How to retrieve and show images from another drive using src attribute in tag? If

Solution 1:

jpgYou can't put your file system path in the src unless you open it from your desktop or your computer. You can try to pass the file as base64 encoded strings. I'm showing how to do it in PHP because you tagged this question with PHP

$image = file_get_contents('d:/Tulips.jpg');

$image_codes = base64_encode($image);

And in your html put it like this.

<imagesrc="data:image/jpg;charset=utf-8;base64,<?phpecho$image_codes; ?>" />

Solution 2:

Try

<imgsrc="file:///d:/Tulips.jpg">

You were missing a slash after your drive lettter.

Solution 3:

The reason is you are doing the inevitable.

HTML markups cannot read data from the local disk drives, you need to put them in a folder or access it from the same directory for this to work.

Since, when you publish your website images are to be accessed from the folders of your webserver, accessing from a hard-drive directly (not possible via HTML though) puts you under potential risks.

Post a Comment for "How To Retrieve And Show Images From Another Drive Using Src Attribute In Tag?"