How to display local images placed on client machine in HTML webpages

后端 未结 3 917
Happy的楠姐
Happy的楠姐 2021-01-13 14:03

How to display local images placed on client machine in HTML webpages hosted on a webserver

I\'m having few images placed in C:/Images folder so path sh

3条回答
  •  感动是毒
    2021-01-13 14:14

    Web pages aren't allowed to access file:/// URLs for security reasons, there is no way around this. However, if you make the same files accessible via another protocol - this can work. For example, you can put the following line into your add-on's chrome.manifest file:

    resource myaddon file:///C:/Images

    This will create a resource protocol alias pointing to that directory - and the resource protocol can be used by webpages. Meaning that the pages will be able to use the image C:\Images\1.jpg as resource://myaddon/1.jpg.

    You can also add resource protocol aliases dynamically. Just make sure you make only images accessible in this way and not all disk content - you might be opening a security hole otherwise.

提交回复
热议问题