简体   繁体   English

将图像作为物理文件存储在服务器上

[英]storing image as physical file on server

我在存储从某些url获取的图像时遇到问题。问题是如何在服务器上存储图像以及在数据库上给出什么路径。如何将图像作为物理文件存储在服务器上,然后在jsp上检索该图像页。

You should make a folder in the project, use this folder to store physical files and give its path in action. 您应该在项目中创建一个文件夹,使用该文件夹存储物理文件并指定其路径。

Online example is here to store image from database to specific folder. 这里的在线示例将图像从数据库存储到特定的文件夹。

Download Code here - Project URL 在此处下载代码 - 项目网址

Your modification is not to store in db but store in your folder, for example if you have stored files in folder "images" 您所做的修改不是存储在db中而是存储在您的文件夹中,例如,如果您已将文件存储在文件夹“ images”中

System.out.println(request.getRealPath("/")+"images\\"+"YourFileName"+".jpg"); 的System.out.println(request.getRealPath( “/”)+ “图像\\” + “YourFileName” + “JPG”);

Above code will give you path of physical path on server. 上面的代码将为您提供服务器上物理路径的路径。

Your Question is possible duplicate of 您的问题可能是的重复项

Struts2: How to store images outside of the webapp and save its path to the db? Struts2:如何在Webapp外部存储图像并将其路径保存到db?

Storing Images in java project dynamically 在Java项目中动态存储图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 需要上传一个 xml 文件,解析并存储在数据库中,而不在任何物理物理位置存储文件 - need to upload an xml file, parse and store in database without storing file at any physical physical location 将文件存储到服务器 - java - Storing a file to server - java 字符串Base64或物理映像文件 - String Base64 or physical image file 在FTP服务器上创建XML文件而不创建物理文件本地 - Create XML file on FTP server without creating physical file localy 存储图像时获取文件路径 - Obtaining File path when storing image 在运行时将图像存储在netbeans中制成的jar文件中 - storing image in jar file made in netbeans at runtime 使用htm输入类型=文件存储图像 - Storing image using htm input type=file 在服务器上存储文件的同时下载文件? 如何将文件的下载功能提供给客户端以在服务器上存储文件? - download file withough storing file on server? How to give download functionality of file to client withought storing file on server? 将用户上传的文件存储在Web服务器中 - Storing user uploaded file in the web-server Java-在FTP服务器上存储文件失败 - Java - Storing File on FTP Server fails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM