Multiple File Uploads with Aptana Jaxer
Date : 2008 03 20 Category : Tech & DevelopmentDealing 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.
PLAIN TEXT HTML:<script type='text/javascript' runat='server'> var message = ""; for (fileCount=0; fileCount <Jaxer.request.files.length; fileCount++){ var fileInfo = Jaxer.request.files[fileCount]; var destinationFilePath = Jaxer.Dir.resolvePath(fileInfo.originalFileName); fileInfo.save(destinationFilePath); message += "<br>" + [ "Saved to : " + destinationFilePath , "original filename : " + fileInfo.originalFileName , "temp filename : " + fileInfo.tempFileName , "contentType : " + fileInfo.contentType , "size : " + fileInfo.fileSize ].join("<br />"); } document.write(message); </script>