The display of the image is separate from handling of the uploaded file.

In fact, the file could be of any type (e.g. .doc, .swf, .xls, .jpg)

Whether you save the image to the db as binary or save it to disk, the image
is acquired from the browser through a separate http request.

If saved on disk, your jsp/html page is typically done with:
<img src="/users/someone/uploaded-image.gif">

If you saved to db then you would need to write something like:
<img src="/app/getImage.do?id=16">

Then have a action class (or action class -> jsp) that handles writing
binary file to browser.
You could:
 -call db layer and get the binary image, then write it using
  response directly from your action
or
 -save the image into a bean and pass to a jsp, then have the jsp do
  the same (Don't forget to set the content type)

Some browsers can have trouble with the second approach, you may need to
specify the type as image/gif or image/jpeg.

How you handle this is completely up to you.

I hope that helps.


James Mitchell
Software Engineer\Struts Evangelist
Struts-Atlanta, the "Open Minded Developer Network"
http://struts-atlanta.open-tools.org

> -----Original Message-----
> From: John Nicholas [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 18, 2002 11:28 AM
> To: [EMAIL PROTECTED]
> Subject: Forms and editing FormFiles
>
>
> I have a file upload field in a form. I was adapting the form to handle
> editing existing entries and ran into a stumbling block. When bringing
> up a pre-populated form that has a file upload field how should I handle
> it? Do I need to load the formfile in the bean? Then what?
>
> Example:
> Let's say I have form to add people and thier pictures to an app
>     Name: _____ <-- reg text input
>     Picture: _____ [Browse] <-- file upload
>
> Now when I bringing this up to edit it and prepopulating from an action
>     Name: John
>     Picture: ______ <-- what should show here? just the file name?
>
>  It seems wasteful to load the image into  the actionform when usually
> I'm not editing it plus I'm not sure the best way to do that. (Any one
> have sample code for loading a FormFile object from a file?)  Maybe not
> on little web gifs but what about a form where people are uploading
> large pdfs. I don't want to force people to reupload everytime. In my
> real app the people editing it later are not usually going to be the
> people who uploaded the binary files. What is the standard behavior for
> this?
>
> Thanks, John
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to