Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
354 views
in Technique[技术] by (71.8m points)

"Not allowed to load local resource: file:///C:....jpg" Java EE Tomcat

I'm trying to retrieve a picture from my file system after a good storage,(instead of putting it in the database I copy it to the disc and i put the path to the db)

  1. I had store the picture to c:images folder and supposing that the name the complete path is c:imagesmypic.jpg
  2. when I try to retrieve it a set the img src attribute to <img src="c:imagesmypic.jps"> by using some java code
  3. in the browser console I found this error Not allowed to load local resource: file:///C://images//mypic.jpg

Question: how to fix these path problem ? where Should I store the pictures ? and from where should I retrieve them ?

question from:https://stackoverflow.com/questions/23969953/not-allowed-to-load-local-resource-file-c-jpg-java-ee-tomcat

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

sending tag <img src="c:imagesmypic.jpg"> would cause user browser to access image from his filesystem. if you have to store images in folder located in c:images i would suggest to create an servlet like images.jsp, that as a parameter takes name of a file, then sets servlet response content to an image/jpg and then loads bytes of image from server location and put it to a response.

But what you use to create your application? is it pure servlet? Spring? JSF?

Here you can find some info about, how to do it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...