File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Opening Image from Uploaded file

 
Budi Saputra
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i use library from www.jfileupload.com. it work for uploading and i put the uploaded file on c:\uploads.

i try to show that image on my page but it can't open.
it seems that the page can't open image outside the war file that i deploy on my web server application.

what path should i use to put the uploaded image to the war file so i can open that image on my page or how can i show the image on my page using my path.
 
Ankit Garg
Sheriff
Posts: 9495
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Budi, don't use a place outside the scope of your application to store the images. When uploading your file, give a relative math to a folder in your application. If you post your source code, then it would be easier to help you.

If indeed you use a folder outside the scope of your application, then you need to create a servlet which will serve the images to clients on requests...
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show your code.

Thats fine to place images outside the application. Suppose, you have lot of images uploaded by users, consider those as user's data, and more are on the way. It simply means you use file system, instead of database, to store user's uploaded images, which is perfectly fine and have some advantages too that outweighs the disadvantages. Another point is, replacing the application war file with a new version, would result in loss of data, otherwise. Further, placing it somewhere else will even make backup/recovery less troublesome.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And yes, please post the exceptions, if any you are getting.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a servlet which reads the image from file system and writes it to response. It is in fact very simple.
You can find here an example: http://balusc.blogspot.com/2007/04/imageservlet.html
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic