How can I display an image from the local machine on a webpage

前端 未结 4 708
南方客
南方客 2020-12-03 19:03

Here\'s the scenario: I have two machines on a LAN network. One of them is acting as a web server. When the second, client machine browser (Firefox) makes a request from the

相关标签:
4条回答
  • 2020-12-03 19:28

    In most recent browsers, links to local files ( file:/// ) do not open, for security purposes. In your case, the browser does not display an image that resides on a file on your hard disk. This reason also explains why it works when you save your page locally.

    0 讨论(0)
  • 2020-12-03 19:32

    A html page cannot request images from the client host. It must be stored on the server, or in another remote location.

    0 讨论(0)
  • 2020-12-03 19:38

    If you are using Arduino you can:

    1. Use embedded css and images. In result you will got whole page by one browser call

    2. Add additional logic to process browser requests for getting css and jpg files from SD card filesystem of Arduino

    0 讨论(0)
  • 2020-12-03 19:44

    For starter, you need to add the runat="server" attribute.

    If that doesn't suffice, then:

    you should change

    <img src="http://localhost//file:/C:/Users/General/Desktop/map1.jpg"/>
    

    to something like

    <img src="http://localhost/General/Desktop/map1.jpg"/>
    

    or even better to

    <img src="~/General/Desktop/map1.jpg"/>
    

    which targets the root of the application (you would need to move your image in that directory)

    0 讨论(0)
提交回复
热议问题