98 | Chapter 4: AIR Mini-Cookbook
Here is the complete code:
<html>
<head>
<title>Browse for Multiple Files</title>
<script type="text/javascript" src="AIRAliases.js">
</script>
<script>
var file = null;
function doLoad( )
{
file = air.File.documentsDirectory;
file.addEventListener( air.FileListEvent.SELECT_MULTIPLE,
doSelect );
document.getElementById( "btnBrowse" ).
addEventListener( "click", doBrowse );
}
function doBrowse( )
{
var filters = new window.runtime.Array( );
filters.push( new air.FileFilter( "Image Files", "*.jpg" ) );
file.browseForOpenMultiple( "Select Photos", filters );
}
function doSelect( event )
{
var elem = null;
var name = null;
var size = null;
for( var f = 0; f < event.files.length; f++ )
{
name = event.files[f].name;
size = Math.ceil( event.files[f].size / 1000 );
elem = document.createElement( "div" );
elem.innerText = name + " (" + size + " KB)";
document.body.appendChild( elem );
}