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

后端 未结 3 873
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:36

    Use the File API which works on all browsers except IE.

    A simple example of this would be:

    function ShowImage(filepath){
        var reader=new FileReader(); // File API object
        reader.onload=function(event){
            document.getElementById('myimage').src = event.target.result;
        }
        reader.readAsDataURL(filepath);
    }
    

提交回复
热议问题