Thursday, March 20th, 2008

Multiple File Uploads with Aptana Jaxer

Category: Aptana, Examples, JavaScript

Dealing with file uploads can be a test of a Web framework. I personally long for the input type="file" to be improved with items such as multiple="true" for multiselection, let alone showing the status of the upload (20% complete).

The Jaxer folks have posted on Easy File Uploading using Aptana Jaxer which shows how you can tinker in JavaScript to get everything you need in a very simple way:

To receive the data from the form when submitted we put some Jaxer code into the page the form will be submitted to. The code below should be in script block with a runat = ‘server’ attribute, which makes the code run serverside and doesn’t present it to the client so you don’t expose any serverside filenames or folder structures.

  1. <script type='text/javascript' runat='server'>
  2. var message = "";
  3.  
  4. for (fileCount=0; fileCount < Jaxer.request.files.length; fileCount++){
  5.    var fileInfo = Jaxer.request.files&#91;fileCount&#93;;
  6.    
  7.    var destinationFilePath = Jaxer.Dir.resolvePath(fileInfo.originalFileName);
  8.    fileInfo.save(destinationFilePath);
  9.  
  10.    message += "<br>" + [
  11.         "Saved to : "           + destinationFilePath
  12.     ,   "original filename : "      + fileInfo.originalFileName
  13.     ,   "temp filename : "      + fileInfo.tempFileName
  14.     ,   "contentType : "        + fileInfo.contentType
  15.     ,   "size : "               + fileInfo.fileSize
  16.     ].join("<br />");
  17.    
  18. }
  19. document.write(message);
  20. </script>

Posted by Dion Almaer at 5:52 am
4 Comments

+++--
3.8 rating from 22 votes

4 Comments »

Comments feed TrackBack URI

It’s still a suprise to me too that non of the big vendors (Microsoft, Sun, etc.) has really solved this problem with a good component. We are using ASP.NET and I tried to find a good upload component. But trying out over 20 different product, the results are rather sad. Specially Safari seems to cause great troubles. My quick and dirty evaluation can found here:
http://remy.supertext.ch/2008/01/file-upload-with-aspnet
I’m very interested in your experience?

Comment by rblaettler — March 20, 2008

This seems to be very simular to ASP.NET’s implementation.

@rblaettler: I use SWFUpload, I think it’s great. There are also ASP.NET demos.

Comment by kim3er — March 20, 2008

@rblaettler: Sorry, just noticed the link on the bottom of your post.

Comment by kim3er — March 20, 2008

I do like SWFUpload too, we use it internally now, but we just had too many issues on the public website with it. I think it’s not an SWFUpload but more of a Flash issues, even Flickr has an alternative Upload tool besides their Flash based tool.

Comment by rblaettler — March 20, 2008

Leave a comment

You must be logged in to post a comment.