Javascript file upload


Is it possible to do a file upload with javascript? Short answer: no. Is it possible to trap file upload events with javascript? the short answer is again no. But there is always a way.

Fortunately in software it's very dangerous to say something is impossible. (People told us Rad SFTP is impossible to build but we built it anyway).

We have just added a new feature to Rad Upload, That makes it very easy to recieve javascript notifications when an upload is completed. In fact it's ridiculously easy. All you need to do is uncomment a single line in the configuration file. Then once the file transfer is completed the applet will call a javascript function named uploadCompleted(). The response returned by the server is passed through as a parameter.

In addition to the callback, Rad Upload exposes two methods that can be invoked by javascripts. These can be used to determine if the last upload was successfull, failed or was cancelled. Another method allows you to retrieve the last response returned by the server.

Now to get back to the original question. Is it possible to do a javascript upload? One solution is to call a method in Rad Upload from your javascript and ask the applet to start uploading. However the method to start the upload has been intentionally kept hidden. No prizes for guessing why.

comments powered by Disqus