[Seaside] Value of a fileUpload element?

Jan van de Sandt jvdsandt at gmail.com
Wed Jan 14 20:21:59 UTC 2009

Thanks for the tip Lukas. Now I have access to the right value using:

            html paragraph: [
                html fileUpload
                    name: 'file';
                    onChange: (html jQuery ajax
                        callback: [ :value | self handleNewFile: value ]
value: (html jQuery this value))].

But for me this is only half the solution. Based on that value I need to
update the values of some hidden input fields in the same form. How can I
add the ajax update in the same onChange code?

As part of the Cloudfork project I am building some Seaside components that
let you upload data directly to an Amazon S3 bucket (
I already have a plain non-ajax version working. Now I'm busy with "ultimate
AJAX S3 upload form". The idea is:

1 developer configures upload component with his aws access keys, bucket
name etc.
2 when a user select a file the component receives a callback. in this
callback he can check whether the file type is allowed and set other S3
upload parameters like the Content-Type.
3 when the user presses submit i want to submit the form using ajax and show
a "please be patient..." message while the upload is in progress
4 when the upload is done S3 returns an XML document with success or error
information, this should be translated to a user information message
5 and it should be possible to have multiple instances of this component
present on a single webpage so multiple uploads can run in paralell.


On Wed, Jan 14, 2009 at 5:39 PM, Lukas Renggli <renggli at gmail.com> wrote:

> > Currently the fileUpload code looks like this:
> >
> >             html paragraph: [
> >                 html fileUpload
> >                     id: (uploadId := html nextId);
> >                     name: 'file';
> >                     onChange: ((html jQuery id: 'pid') load
> >                         addParameter: 'dummy' -> ((html jQuery id:
> uploadId)
> > value);
> >                         html: [ :h | self hanldeNewFile: h. h text:
> 'Haai'
> > ])].
> File uploads and Javascript are hairy. You cannot easily serialize a
> file and submit it through an AJAX request, due to security
> restrictions in JavaScript. Some sites use a little IFRAME to be able
> to make a traditional submit without having a full refresh of the
> complete page. Other sites use a Flash or Java applet. Have a look at
> the JQuery Plugins
> (http://plugins.jquery.com/search/node/upload+type%3Aproject_project),
> there are quite a few providing different solutions to this problem.
> > Can anobody tell me how I can read the parameter value from the callback
> > block?
> #addParameter: is a low level function. It modifies the URL.
> Use #callback:value: instead, this is the high level interface. It
> expects a block that will be evaluated with the evaluation of the
> Javascript object given as a second parameter. Look at the senders of
> this method to see some examples.
> Cheers,
> Lukas
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20090114/15c14e0c/attachment.htm

More information about the seaside mailing list