0

I have a php website on a web hosting however, i would like to open some files in a specific path on the viewers' local pc. in other words, they click in a page of my website and the page will open some local files in their pc

like the following, can i just refer to the local c: drive?

<!DOCTYPE html>
<html>
    <head>
    </head>

    <body>
        <img src='c:\xxx\xxx\xxx.jpg'>
    </body>
</html>
Álvaro González
  • 142,137
  • 41
  • 261
  • 360
Ray Lee
  • 25
  • 3
  • Kindly post some of your efforts/code then only we can help you also refer to this [ask]. – Prabhjot Singh Kainth Dec 27 '19 at 05:15
  • thanks for the comment. I have added some codes to describe my question. hope this help =D – Ray Lee Dec 27 '19 at 05:22
  • How is this related to `PHP`? What if the image file doesn't exist? What if the user doesn't have a `C:` drive, like Linux/Mac users? – brombeer Dec 27 '19 at 07:17
  • PHP actually runs on the web hosting server so, from its perspective, those are **remote** files, not local ones. In any case, I'm retagging this question because I don't think it has anything to do with PHP in the first place. – Álvaro González Dec 27 '19 at 13:15
  • the page is not for public users. actually i would like to show image from local disk once the network is down – Ray Lee Dec 30 '19 at 06:15

1 Answers1

0

You need to use the file:/// protocol if you want to link to local files.

<img src="file:///c:\xxx\xxx\xxx.jpg">

The file:/// protocol is used in a URI that specifies the location of an operating system file. The URI includes the host name, port, and path to the file.

If there is space in the path then add %20, as it will be read by your browser as a space.

Prabhjot Singh Kainth
  • 1,831
  • 2
  • 18
  • 26