On Tue, 19 Jan 2010 15:43:18 +0100, Vladislav Vorobiev wrote:
> Hello!
>
> I need to send an Formular with Content-Type „ multipart/form-data“.
> The File that I send is a image. Kss send it as a string.
>
> Kss send something like this.
> Content-Type: application/x-www-form-urlencoded; charset=UTF-8
>
> form.image=1.JPG
>
> It must be like this.
>
> Content-Type: multipart/form-data;
> Content-Disposition: form-data; name="form.image"; filename="1.JPG"
>
> Content-Type: image/jpeg
>
> ÿØÿàCONTENTCONTENTCONTENT_DATA.
>
> My kss:
>
> #bla:click {
> evt-click-preventdefault: true;
> evt-click-allowbubbling: true;
> action-server: testKss;
> testKss-kssSubmitForm: currentForm();
> }
>
> My form:
>
> <form id="zc.page.browser_form" class="edit-form"
> enctype="multipart/form-data" method="post" action="/action">
>
> <input type="file" size="20" name="form.image" id="form.image"
> class="fileType"/>
>
> <input type=“submit“ id=“bla“ /> </form>
>
> How I can tell KSS to send my form multipart/form-data? Can't find this
> feature in in the Doku.
In general, when KSS executes a server action, it makes an
XMLHttpRequest. XMLHttpRequest is only capable of downloading, it is not
capable of uploading a file. The lack of ajax file upload is not a
limitation of KSS but a limitation built into the browsers, partly
intentionally (security concerns), partly due to lack of support for
these features in a cross-browser compatible api.
In the new Firefoxes (3.6 and above), XMLHttpRequest _can_ be used for
uploading, with some caveats. Needless to say, no other browsers support
this. However, even in this case, there is no way to access any files
from the filesystem by program code. The user needs to actually go
through the browse dialog and select the file. So but again, this would
not work on all browsers.
There is a workaround that still makes it possible to upload files with
ajax. The trick is to create a hidden form in an iframe. The actual
<input type="file"> tag then needs to be copied into this form, after the
user has already selected the file into it. Later on, the form will be
submitted as a form, not as an XMLHttpRequest. There is existing
javascript code that does this for you, so someone could make a simple
wrapper for this code as a kss plugin which would make it possible to
work this way. There is however no chance really, that the standard
action-server would ever support this: it would be a plugin on its own.
--
Balazs Ree Greenfinity LLC.
Python, Zope, Plone http://greenfinity.hu
_______________________________________________
Kss-devel mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kss-devel