• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Opening Image from Uploaded file

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And yes, please post the exceptions, if any you are getting.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic