cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Siraj Shakil <>
Subject Re: How to save uploaded files?
Date Wed, 06 Aug 2003 03:30:26 GMT
Hello Sonny,

Well, i faced the same problem that you do .. so wrote
a file uplaoder logicsheet that can handle uploads for
"autosave-uploads" set to both true or false. 

Here is a sample code:

<file-uploader:upload-file param-name="upload_file">

And it also works for multiple file uploads to the
same XSP page.

I can give you the code if you want, for
documentation, i havn't finished it yeat, will do
ASAP. But i am sure you can get the functions looking
at the code.

By the way, is there any way i can donate this code to
cocoon project? i need some guidelines since i am no
good with CVS.

Answers to few of your questions:

Yes, you have to save the file at the server anyway to
show it in a browser. If you want to have a reference
to the image later on from the webpage, you have to
pass a form variable with the value set to the file
name. i.e. if i save a temporary file name and want to
show it i write HTML code like <input tupe="hidden"
name="tmp_file" value="123123123.jpg"/>. Then i simply
look into the HTTP variable to get the file name
submitted XSP page. 

There is no way the webserver will know if someone is
done previewing. So one way is to delete the file when
someone clicks on a link "I am done" or you can write
a script that will look into the folder and delete any
file which has exceeded a certain amount of time, lets
say 30 mins? Then you simply use any scheduler
programs i.e. CronD, windows schedular, etc. and call
that script time to time:>. saves a lot of hassle.

So, give me a buzz if you need the code. Best of luck.

Best regards,

--- Sonny Sukumar <> wrote:
> Thanks for the tip, Geoff.
> The WIki doesn't seem to give me quite enough info. 
> Step by step, my 
> thinking is as follows:
> 1.) If I set "autosave-uploads" to false, then I
> have to retrieve an 
> uploaded file from memory as a FilePartArray,
> correct?
> 2.) Assuming I now have a FilePartArray in my Cocoon
> action which processed 
> the upload, I'd like to make the image file
> accessible for a later 
> processing step to embed a reference to the image in
> the HTML doc sent back 
> to the client.
> 3.) Now, it seems like that reference can only be a
> file path, which means 
> the images would need to be saved to disk on the
> server anyway.
> 4.) My problem with that is that I don't want the
> photos to end up in server 
> storage for good, as I don't know of a way to always
> get a message from the 
> client (browser) specifying if a person is done
> previewing.  If they end up 
> saving the product, I'd know, but what if they just
> close their window?
> I'd appreciate your thoughts, as I'm not sure how to
> proceed.
> Sonny
> >From: Geoff Howard <>
> >Reply-To:
> >To:
> >Subject: Re: How to save uploaded files?
> >Date: Tue, 05 Aug 2003 15:14:48 -0400
> >
> >Search the wiki for "upload"
> >
> >Sonny Sukumar wrote:
> >>
> >>If I want to keep the "autosave-uploads" param =
> false in web.xml, then 
> >>how would I save certain files that I want to?
> >>
> >>More specifically, sometimes I just want the user
> to be able to preview a 
> >>photo next to other data but I don't want to save
> it.  Other times I 
> >>specifically want to save all form data, including
> the uploaded photos 
> >>that come along in the multi-part form data.
> >>
> >>What's the best way to implement this dual
> preview/save functionality?
> >>
> >>Thanks,
> >>
> >>Sonny
> >
> >
> >To unsubscribe, e-mail:
> >For additional commands, e-mail:
> >
> Help STOP SPAM with the new MSN 8 and get 2 months
> FREE*  
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message