#!/usr/bin/perl
#
  do "acqPATHs.pl";
  $wdr = $ENV{"QUERY_STRING"};
  print "Content-type: text/html; charset=iso-8859-1\n\n";
#
  $htmlbody =<<EOM;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<link rel="stylesheet" type="text/css" href="/AMXS/amxs.css">
<title>AMXS upload</title>
<script type="text/javascript">
<!--
function cancel() {
  location.replace("/AMXS/forms/blank.html");
}
//-->
</script>
</head>
<body bgcolor="ivory" style="margin: 4px 7px;">
<form name="FM" method="POST" action="/cgi/AMXS/upload2.cgi"
 enctype="multipart/form-data">
<hr>
<big><b> &nbsp; Upload Data File</b></big> &nbsp;
 (ASCII text format only)<br>
<table>
<tr><td>Destination Filename:</td>
 <td><input type="text" name="rfnm" size=16></td>
 <td>(Preceding "<b>.</b>" and non-Alphanumerics<br>
  are taken away.)</td></tr>
<tr><td>Source file on your PC:</td>
 <td colspan=2><input type="file" name="lfnm" size=32></td></tr>
<tr><td></td>
 <td colspan=2><input type="button" value="UPLOAD" onclick="submit()">
  <input type="radio" name="ascbin" value="asc"
   id="Asc"><label for="Asc">ASCII</label> &nbsp;
  <input type="radio" name="ascbin" value="bin" checked
   id="Bin"><label for="Bin">Binary</label> &nbsp; &nbsp; &nbsp; &nbsp;
  <input type="button" value="cancel" onclick="cancel()">
  <input type="hidden" name="wdr" value="__WDR__"></td></tr>
</table>
<table>
<tr><td colspan=6><i>Existing Files</i> :</td></tr>
EOM
  $htmlbody =~ s/__WDR__/$wdr/;
  print $htmlbody;
#
  $n = 0;
  open(IN, "ls -F $DATAPATH/$wdr |");
  while ($fnam=<IN>) { chop($fnam); $dnam[$n] = $fnam; $n++; }
  close(IN);
  $nl = ($n + 5 - (($n-1) % 6)) / 6;
  for ($l=0; $l<$nl; $l++) {
    print " <tr>\n";
    for ($c=0; $c<6; $c++) {
      $m = $c*$nl + $l;
      if ($m < $n) { print "  <td> &nbsp; " . $dnam[$m] . "</td>\n"; }
      else { print "  <td> &nbsp; </td>\n"; }
    }
    print " </tr>\n";
  }
#
  print "</table>\n</form>\n</body>\n</html>\n";
  exit(0);
