The following Javascript code is used to upload a single image from the PC to the server.

File location: /wsd-samples/uploadimage.js

<script language="JavaScript">
<!--
var image_field;
var popup_window;

function update_image_list() {
   var length = image_field.length;
   var filename = popup_window.document.OkForm.UploadedFilename.value;
   image_field.options[length] = new Option(filename,filename);
   image_field.selectedIndex = length;
   popup_window.close();
}

function upload_image(uploaddir,image_field_var) {
   image_field = image_field_var;
  varwindow_opts='toolbar=no,location=no,directories=no,status=no,' +
     'width=500,height=150,menubar=no,scrollbars=yes,resizable=yes';
   win = window.open('','upload_image',window_opts);
   popup_window = win;
   win.document.writeln('<html>');
   win.document.writeln('<head><title>Upload Image</title></head>');
   win.document.writeln('<body bgcolor="#D5ECFB">');
   win.document.writeln('<form method="POST" action="<$prop:submiturl$>/uploadnew" enctype="multipart/form-data">');
   win.document.writeln('<input type=hidden name="_JavaScript" value="Yes">');
   win.document.writeln('<input type=hidden name="CurrentDir" value="' + uploaddir + '">');
   win.document.writeln('<input type=hidden name="Stage" value="99">');
   win.document.write('<input type=hidden name="PopupClose" value="');
   win.document.writeln('opener.update_image_list()">');
   win.document.writeln('<table border=0 cellspacing=0 cellpadding=5 align=center>');
   win.document.writeln('<tr><td align="right"><b>Image to Upload: </b></td>');
   win.document.writeln('<td align="left"><input type="file" size="30" name="UploadFile"></td></tr>');
   win.document.writeln('<tr><td align="right"><b>Image Title: </b></td>');
   win.document.writeln('<td align="left"><input type="text" size="30" name="title"></td></tr>');
   win.document.writeln('<td align="center" colspan="2">');
   win.document.writeln('<input type="submit" name="submit_button" value="Upload Image">');
   win.document.writeln('&nbsp;&nbsp;<input type=button value="Cancel" onClick="self.close();">');
   win.document.writeln('</td>');
   win.document.writeln('</form>');
   win.document.writeln('</body>');
   win.document.writeln('</html>');
   win.document.close();
   win.focus();
}
//-->
</script>

Copyright 2000-2005 CyberTeams, Inc., http://www.cyberteams.com All rights reserved.
CyberTeams and WebSite Director are registered trademarks of CyberTeams, Inc. All other marks are the property of their respective owners.