简体   繁体   中英

Not allowed to load local resource: file:///D://foldername//filename.jpg

Actually I have to upload 20000 images into mysql database if I store all images to Mysql database as Blob type the performance is reduced and It will slow down if we upload other images if required.To avoid this problem I am storing all images into folder and their path's into mysql database table.and retriving these images with pagination . now data is showing in table but images are not displaying.

String sb1 = new String("file://");
String sb2=new String(user.getPlaceImage());

out.println("<td><img src="+sb1.concat(sb2)+"  width='70' height='50' /></td>");

If there is any alternative way to deal with this problem?

Here is a basic alternative technique that I use to serve images to users: Create a folder outside your website root so users won't have direct access to the files using HTTP. Let's say you already have a database table that contains URI to all the images. Create a interface file, for instance: getimage.jsp?id=42 that serves user the requested image file. Also, if you are storing relative URLs in the database you need to be extra careful because you might be trying to read the file from a wrong path in relation to your JSP file that's trying to access the image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM