• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

How to refer uploaded file

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

i searched a lot for this one before posting this.

my requirement in brief:
i)User selects an image.
ii)I need to read the image
iii)Store it in server's file system. (Not in database as BLOB)
iv)The image selected by the user should be made visible in a page. so i need to give a reference to the image uploaded thru src attribute in img tag of the webpage.

now the problem is how to accomplish the iii) and iv) steps. i'm able to read the file from client machine thru MultiPart concept and i'm able to accomplish the first 2 steps.

the problem becomes tricky bcoz all the clients shud be able to see the image and we need to set the src attribute such a way that it is global and not specific to any client/server's file system.

i tried to give relative path, but its not working.

am i missing something which is very simple.
help is appreciated
[ June 14, 2005: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
How are you organizing the storage of your user uploaded files. Means, where exactly (in which folder) is those files stored.

Is it along with the webpart of the application ? , ie along with the META-INF folder and currently how are you accessing it and what is the problem you are facing ?
 
Sai Shrawan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanx for the quick reply.

i'll make my pblm clearer. i'm able to read the file from the client machine ... means i'm getting the bytes.
now my question is how to write those bytes to a file and where to store it so that it can be referenced by all the clients.
 
Senthil B Kumar
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i guess we need information like where are you now currently storing your file (ie in which folder exactly).

For example, you can create an UserFiles folder in the Web part, along with the WEB-INF folder. Then write your files to this folder, note that it is better to use a relative path (relative to the context root of the application) to mention where to write the files.

Basically its relative and relative to context root of the application.
 
Sai Shrawan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanx for the hint.

this is what i was looking for, where to store the client file.
stored here:request.getSession().getServletContext().getRealPath("/")

and then used relative path as u said for referring the file on server.

thanx again
reply
    Bookmark Topic Watch Topic
  • New Topic