-3

I am working in an Angular4 application ,In this I need to refer image from my local disk instead of referring from assets folder.But in my case it is not working for me .

HTML

<div class="col-sm-12">
<img src="F:\my_Images" alt="img">
</div>

By using this line the image is not get displayed.

Thanks.

Nikson
  • 900
  • 2
  • 21
  • 51

2 Answers2

0

Modern Browsers generally doesn't allow to access the local file system directly as it is security vulnerability..You could run the html file stored locally..But it will not work once you deploy it to a web server. Still if you want do that, you could build a browser extension - Firefox extensions and IE extensions can access local resources. Chrome is much more restrictive however.

Alternately, you can upload the image from local folder ,if it fulfills your requirement.

Rak2018
  • 935
  • 6
  • 16
-1

Dude that's not recommended keep a folder in your app named "assets " and put your images in it.or to make your life easy use base 64 image encoder checkout this link link

and then keep your image like this

<img width="300" alt="Angular Logo" src="data:image/jpeg;base64,<Your Base 64 image code>">
Deepak Mani
  • 125
  • 11
  • So in Angular we cannot refer the image from outside of the assets folder right ..? – Nikson Apr 13 '18 at 10:30
  • No you can refer the image from outsie of the assets folder but it should be in your app main folder – Aarsh Apr 13 '18 at 10:39
  • Deepak Mani ,Please take a look at this https://stackoverflow.com/questions/46710642/angular-cli-how-can-i-access-images-outside-of-the-assets-folder – Nikson Apr 13 '18 at 10:44
  • Yes as you can see I gave you multiple approaches to resolve your situation – Deepak Mani Apr 13 '18 at 11:37