-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload.php
52 lines (41 loc) · 1021 Bytes
/
upload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
if (!empty($_FILES['file'])) {
foreach ($_FILES['file']['name'] as $key => $name) {
if ($_FILES['file']['error'][$key] == 0 && move_uploaded_file($_FILES['file']['tmp_name'][$key], "files/{$name}")) {
$uploaded[] = $name;
}
}
if (!empty($_POST['ajax'])) {
die(json_encode($uploaded));
}
}
?>
<html>
<head>
<title>file uploader</title>
<script type="text/javascript" src="upload.js"></script>
<style type="text/css">
#upload_progress { display: none; }
</style>
</head>
<body>
<div id="uploaded">
<?php
if (!empty($uploaded)) {
foreach ($uploaded as $name) {
echo '<div><a href="files/', $name,'">', $name, '</a></div>';
}
}
?>
</div>
<div id="upload_progress"></div>
<div>
<form action="" method="POST" enctype="multipart/form-data">
<div>
<input type="file" id="file" name="file[]" multiple="multiple" />
<input type="submit" id="submit" value="Upload">
</div>
</form>
</div>
</body>
</html>