[Seaside] Value of a fileUpload element?

Lukas Renggli renggli at gmail.com
Wed Jan 14 16:39:56 UTC 2009


> 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


More information about the seaside mailing list