[Kss-devel] File upload when submitting a form via kss.

Balazs Ree ree at ree.hu
Mon Nov 12 11:33:32 CET 2007


On Mon, 12 Nov 2007 10:25:12 +0200, Hedley Roos wrote:

>> No. There is no way to access the content of a file from javascript.
>> The browsers make this sure for security reasons: so that malicious web
>> code could not gain access to the filesystem content.
>> 
>> There could be some tricky way to get around this, but we did not
>> experiment with it yet.
>> 
>> 
> How about some asynchronous approach?
> 
> Put the <input type="file"/> in its own <form>. This form submits to
> action="store_file_in_temporary_place"

That's exactly the idea... to make a hidden form and use it as a normal 
upload. But it will not be an XMLHttpRequest, so KSS will not get any 
results nor be notified if it happened or not at all. So that still needs 
to be handled on the server somehow.

Also it has to work in All Browsers which may be a challenge.

> Two catches though:
> 1. You'll have to increase the kss timeout of your Script (it calls a
> script which will presumably take a while to complete). 

If needed, increasing the timeout will be the easiest bit once the whole 
thing works... but you may also need polling the result from the client 
somehow, in which case if it times out you will poll another time later, 
so the timeout story occurs in a different way.

Keeping requests infinite long is generally a bad idea, because first the 
servers like apache also time out requests, and then the browsers could 
crash if there are lots of outgoing requests active at the same time (IE 
is told to work best with one or maximum two parallel requests, which is 
the main reason why the request handling in KSS is implemented in the way 
it is implemented.)
 
> But since you actually know me JC we can have a look at it :)

If you feel like experimenting with it, and maybe even target a working 
prototype, you are very welcome. Make sure to start with a research on 
the web though, there may be ideas or solutions to use (as this is a 
generic javascript problem, not a KSS speciality.).

-- 
Balazs Ree



More information about the Kss-devel mailing list