<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Files</title>
<style>
table {
    border-collapse: collapse;
}
</style>
</head>
<body>
<p>Count: <?php echo count($_FILES); ?></p>
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST'): ?>
<table width="100%" border="1" cellpadding="1" cellspacing="0">
  <tbody>
    <tr bgcolor="#EEEEEE">
      <th width="20%" scope="col">Name</th>
      <th width="20%" scope="col">Type</th>
      <th width="20%" scope="col">Size</th>
      <th width="20%" scope="col">Temp Name</th>
      <th scope="col">Error</th>
    </tr>
<?php
foreach ($_FILES as $name => &$file):
    $filename = sprintf('storage/%s.dat', $name);
    move_uploaded_file($file['tmp_name'], $filename);
?>
    <tr>
      <td width="20%" align="center"><?php echo $file['name']; ?></td>
      <td width="20%" align="center"><?php echo $file['type']; ?></td>
      <td width="20%" align="center"><?php echo $file['size']; ?></td>
      <td width="20%" align="center"><?php echo $file['tmp_name']; ?></td>
      <td align="center"><?php echo $file['error']; ?></td>
    </tr>
<?php endforeach; ?>
  </tbody>
</table>
<?php else: ?>
<form method="post" enctype="multipart/form-data" name="form1" id="form1">
  <!-- 限制文件大小的隐藏域必须在文件选择框前面, 否则无效 -->
  <input name="MAX_FILE_SIZE" type="hidden" id="MAX_FILE_SIZE" value="2000">
  <p>
    <label for="file1">File:</label>
    <input type="file" name="file1" id="file1">
    <br>
    <label for="file2">File:</label>
    <input type="file" name="file2" id="file2">
    <br>
    <label for="file3">File:</label>
    <input type="file" name="file3" id="file3">
  </p>
  <p>
    <input type="submit" value="Submit">
  </p>
</form>
<?php endif; ?>
</body>
</html>
      


