• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Opening Image from Uploaded file

 
Greenhorn
Posts: 7
  • 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.
 
Sheriff
Posts: 9671
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • 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...
 
Ranch Hand
Posts: 2874
  • 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
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Every time you till, you lose 30% of your organic matter. But this tiny ad is durable:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic