|
| 1 | +<?php |
| 2 | +$header_prefix = 'file'; |
| 3 | +?> |
| 4 | +<html> |
| 5 | +<head> |
| 6 | +<title>Test upload</title> |
| 7 | +</head> |
| 8 | +<body> |
| 9 | +<? |
| 10 | +if ($_POST){ |
| 11 | + echo "<h2>Uploaded files:</h2>"; |
| 12 | + |
| 13 | + echo "<table border=\"2\" cellpadding=\"2\">"; |
| 14 | + |
| 15 | + echo "<tr><td>Archive path</td><td>File name</td><td>Location</td><td>Content type</td><td>MD5</td><td>Size</tr>"; |
| 16 | + |
| 17 | + $fdesc_keys = array_keys($_POST); |
| 18 | + |
| 19 | + foreach($fdesc_keys as $fdesc_key) { |
| 20 | + if(strpos($fdesc_key, $header_prefix) == 0 && |
| 21 | + strpos($fdesc_key, "_name") > 0) { |
| 22 | + $key = substr($fdesc_key, 0, count($fdesc_key) - 6); |
| 23 | + |
| 24 | + if (array_key_exists($key."_name", $_POST) && array_key_exists($key."_path",$_POST)) { |
| 25 | + $archive_path = $_POST[$key."_archive_path"]; |
| 26 | + $tmp_name = $_POST[$key."_path"]; |
| 27 | + $name = $_POST[$key."_name"]; |
| 28 | + $content_type = $_POST[$key."_content_type"]; |
| 29 | + $md5 = $_POST[$key."_md5"]; |
| 30 | + $size = $_POST[$key."_size"]; |
| 31 | + |
| 32 | + echo "<tr><td>$archive_path</td><td>$name</td><td>$tmp_name</td><td>$content_type</td><td>$md5</td><td>$size</td>"; |
| 33 | + } |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + echo "</table>"; |
| 38 | + |
| 39 | +}else{?> |
| 40 | +<h2>Select files to upload</h2> |
| 41 | +<form name="upload" method="POST" enctype="multipart/form-data" action="/upload"> |
| 42 | +<input type="file" name="file1"><br> |
| 43 | +<input type="file" name="file2"><br> |
| 44 | +<input type="file" name="file3"><br> |
| 45 | +<input type="file" name="file4"><br> |
| 46 | +<input type="file" name="file5"><br> |
| 47 | +<input type="file" name="file6"><br> |
| 48 | +<input type="submit" name="submit" value="Upload"> |
| 49 | +<input type="hidden" name="test" value="value"> |
| 50 | +</form> |
| 51 | +<?} |
| 52 | +?> |
| 53 | +</body> |
| 54 | +</html> |
0 commit comments