0

After some research What is the best place for storing uploaded images, SQL database or disk file system?, I decided to store the uploaded pictures on file system e.g. C:/images/image.jpg, and store this path into a database. Now when I want to display the picture by setting attribute src="C:/images/image.jpg" I get error in console -

Not allowed to load local resource:

What is the proper way to display images stored in filesystem ?

Community
  • 1
  • 1
MNJ
  • 172
  • 1
  • 1
  • 13
  • please show your code – elementzero23 Jan 25 '17 at 08:30
  • 3
    `I decided to store the uploaded pictures on file system e.g. C:/images/image.jpg` You can't access the file system of the client machine through JS as it's a security violation. – Rory McCrossan Jan 25 '17 at 08:31
  • @RoryMcCrossan I am aware of this, what do you suggest, storing in different location after upload ? – MNJ Jan 25 '17 at 08:34
  • Yes - normally on the server if you need to retain the file. It depends on exactly what your use case is – Rory McCrossan Jan 25 '17 at 08:35
  • You are storing image at your server, and trying to access it from clients' machine. You have to put the path of the image of your server. It should look like. http:://www.myserver.com/path-to-img-folder/img.jpg – Shubhranshu Jan 25 '17 at 08:35

1 Answers1

0

I found this site https://howtoprogramwithjava.com/how-to-display-images-stored-on-a-server/ which solved my issue. I had to setup a context path for the webapp.

MNJ
  • 172
  • 1
  • 1
  • 13