File upload progress and CF

posted: 18 Mar 2008

I'm working on a video project at work, where we need to provide visual feedback on a file upload. You know the sort, fill in the form, pick your file, hit submit and watch the progress bar tell you how much has been uploaded.

Well my initial thought was that ColdFusion would be able to do this, submit to a hidden iframe and then monitor the files size, however, it appears CF won't even start to process the script until the entire request, file and all, has been received. So by the time you can do anything scripty, the process is already complete. Even if the script doesn't use the file, it gets it ready to process just in case.

So I turned my gaze to Java, CF being Java meant I could maybe sit a jsp alongside my CF pages, and I found FileUpload from those great guys at the Apache Foundation. The latest incarnation (1.2 I think) of FileUpload has the ability to watch the upload progress. You basically register an event handler class to the update() method of FileUpload.

So I got my Java books out and went to work on revising inner classes. I now have two jsp pages, one that accepts the form with an inner class that writes the percentage complete, and other status' to an application variable, and a second that provides a monitor on this status.

On submit of the form, JavaScript rewrites the form submission, hides the submit button, reveals the progress bar, creates a hidden iframe and submits the form to it. It then sets up an asynchronous XHR to watch it's progress. The monitor jsp file feeds back the progress and the page updates a set of divs that make up the progress bar. Once the file is uploaded a 'new' status is returned to the browser and the page redirects to a static 'success' page.

I am thinking about posting an example of the code, once I've ironed out any wrinkles.


Made me laugh

posted: 16 Mar 2008

Just watching a show where they follow a guy looking to get fit. He has his body fat measured and the conversation goes:

trainer: You have 26% body fat, a healthy male should be below 20.
him: Is there any chance the machine could be wrong?
trainer: No chance at all. This machine is 99% accurate.

Awesome (well it made me laugh)


New phone

posted: 13 Mar 2008

So, it's my birthday approaching and my lovely lady was completely out of ideas on what she could buy me as a present. And I'd been thinking about replacing my Treo 650 for some time. Not only had I dropped it a few too many times and it was starting to reboot for no reason, but I was paying for unlimited 3G bandwidth on the free Razr v3xx I got when I signed with AT&T and couldn't use it on the old Treo. (it would work on GPRS.)

So what to do? Well my requirements weren't too strict, I wanted Bluetooth, but not necessarily for a headset, 3G was a must, a large screen was also a must (after browsing on the Razr) and a touch screen would be preferable. I loved the Palm (Access) OS, but wasn't going to be tied to it and I also loved the old Treo keyboard.

Well, after some pretty thorough, though not languishing, research, I plumped for the Treo 750. The device is similar enough to my old Treo to be familiar, but with Windows OS and a slightly better screen. At the outset, I liked it, but it was certainly going to be a learning curve.

First impressions, over the old Palm/Access OS is that despite the improved hardware, the response of the interface is not as good. Much like it's desktop cousin, the software seems to always require slghtly more than the hardware's got to give. There is a definite delay on opening an application that after the old phone, kinda sucks.

The applications that come with the device are adequate, the most useful being the Office Mobile suite. I used to be a big fan of the Notes app on the old phone and the power of greater editing sounds very attractive (although I haven't used it yet!) Having a file explorer bundled is a bonus, I know there was FileZ on the old OS, but still, an improvement there.

Besides that, my biggest gripe is Internet Explorer. The mobile edition is a total pile. It renders css badly, cannot zoom, is not very configurable and is generally an unpleasant experience to use. Within 48 hours of owning the device I had installed the trial version of Opera. I suspect the full version will follow pretty soon.

The biggest plus, I think, is the 'broadband' speeds. Coverage is now pretty good and with the full colour high(ish) resolution screen, browsing is very possible.

Would I recommend it? Yes. The combination of touchscreen, 3G and form factor make it the best of what's out there for me.