- commit
- 2be01b94e6309802611775c5e2b73595bad1dc5d
- parent
- 7101a546420ffcf4ae4210eb2ccb60b04eaf911f
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2018-10-20 13:13
upload: allow to create folders
Diffstat
| M | index.php | 13 | ++++++++++++- |
| M | templates/uploads.html | 8 | +++++++- |
2 files changed, 19 insertions, 2 deletions
diff --git a/index.php b/index.php
@@ -200,6 +200,12 @@ class Pupupu 200 200 move_uploaded_file($file['tmp_name'], $p); 201 201 } 202 202 -1 203 public function uploadFolder($path, $name) -1 204 { -1 205 $p = $this->targetDir . '/files' . $path . '/' . $name; -1 206 mkdirp($p); -1 207 } -1 208 203 209 public function getUploads($path) 204 210 { 205 211 $uploads = array(); @@ -296,9 +302,14 @@ function uploadView($pupupu, $twig) 296 302 } elseif (isset($_FILES['file'])) { 297 303 $pupupu->upload($path, $_FILES['file']); 298 304 header("Location: ", true, 302);299 -1 } else {-1 305 } elseif (isset($_POST['folder'])) { -1 306 $pupupu->uploadFolder($path, $_POST['folder']); -1 307 header("Location: ", true, 302); -1 308 } elseif (isset($_POST['delete'])) { 300 309 $pupupu->rmUpload($path . '/' . $_POST['name']); 301 310 header("Location: ", true, 302); -1 311 } else { -1 312 http_response_code(400); 302 313 } 303 314 } 304 315
diff --git a/templates/uploads.html b/templates/uploads.html
@@ -27,7 +27,13 @@ 27 27 <li> 28 28 <form method="post" enctype="multipart/form-data" class="flex-ignore"> 29 29 <input type="file" name="file" class="input--invisible file-list__main">30 -1 <input type="submit" value="{{ 'Upload'|trans }}" class="button--small">-1 30 <input type="submit" value="{{ 'Upload file'|trans }}" class="button--small"> -1 31 </form> -1 32 </li> -1 33 <li> -1 34 <form method="post" class="flex-ignore"> -1 35 <input type="text" name="folder" placeholder="{{ 'name'|trans }}" class="input--invisible file-list__main"> -1 36 <input type="submit" value="{{ 'Create folder'|trans }}" class="button--small"> 31 37 </form> 32 38 </li> 33 39 </ul>