Javascript upload

2004 March 16 at 10:19 » Tagged as :javascript, radinks, upload,

A common question in many newsgroups or mailing lists is "how can I upload files using JavaScript?" Unfortunately, the answer is not straightforward as there is no direct method to achieve this.

Why didn't I just say you can't do it? well nothing is impossible for a good programmer. For example before we came out with our SFTP applet most experts were calling this kind of software impossible to build. But that's Java, lets' get back to Javascript. (Another gripe is the number of people who post javascript questions in java groups)

Getting back to The javascript documentation does refer to an onDragDrop event that will be invoked when a file is dropped onto the browser. In order for your javascript to respond to this event it needs to be a signed javascript. Unfortunately the behaviour of signed scripts have all changed along with lots of other thigns in mozilla 1.4+ but it's not fully documented (yet).

Even if you managed to gain access to the files by listening on the onDragDrop event, making a mime message that the server side upload handler can accept is a different kettle of fish.

At Rad Inkswe have received multiple requests for a JavaScript uploader similar to Rad Upload On a few occasions, we have customized Rad Upload to trigger a JavaScript event upon completion of the upload process. This approach does not require signed JavaScripts, although the applet itself is signed.

On another occasion we went the other way, the upload routine in Rad Upload was invoked by a javascript - which is a round about way of uploading files with javascript.