- commit
- 7101a546420ffcf4ae4210eb2ccb60b04eaf911f
- parent
- ff6f155d360460705b0511f7ee5ae57b450be18f
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2018-10-20 12:55
upload: allow to remove folders
Diffstat
| M | index.php | 18 | +++++++++++++++++- |
| M | templates/uploads.html | 9 | ++++++--- |
2 files changed, 23 insertions, 4 deletions
diff --git a/index.php b/index.php
@@ -28,6 +28,22 @@ function rmfile($path) 28 28 rmdirs(dirname($path)); 29 29 } 30 30 -1 31 function rmr($path) -1 32 { -1 33 if (file_exists($path)) { -1 34 if (is_dir($path)) { -1 35 foreach (scandir($path) as $name) { -1 36 if ($name !== '.' && $name !== '..') { -1 37 rmr("$path/$name"); -1 38 } -1 39 } -1 40 rmdir($path); -1 41 } else { -1 42 unlink($path); -1 43 } -1 44 } -1 45 } -1 46 31 47 function mkdirp($path) 32 48 { 33 49 if (!file_exists($path)) { @@ -211,7 +227,7 @@ class Pupupu 211 227 212 228 public function rmUpload($path) 213 229 {214 -1 unlink($this->targetDir . '/files' . $path);-1 230 rmr($this->targetDir . '/files' . $path); 215 231 } 216 232 217 233 public function render($path, $verbose=false)
diff --git a/templates/uploads.html b/templates/uploads.html
@@ -11,13 +11,16 @@ 11 11 <img src="static/file.png" class="file-list__icon" alt="{{ 'file'|trans }}"> 12 12 {% endif %} 13 13 <a href="{{ file.url }}" target="_blank" class="file-list__main">{{ file.name }}</a> -1 14 {% else %} -1 15 <img src="static/folder.png" class="file-list__icon" alt="{{ 'folder'|trans }}"> -1 16 <a href="?path=_uploads{{ file.path }}" class="file-list__main">{{ file.name }}/</a> -1 17 {% endif %} -1 18 -1 19 {% if file.name != '..' %} 14 20 <form method="post"> 15 21 <input type="hidden" name="name" value="{{ file.name }}"> 16 22 <button class="button--danger button--small" name="delete">{{ 'Delete'|trans }}</button> 17 23 </form>18 -1 {% else %}19 -1 <img src="static/folder.png" class="file-list__icon" alt="{{ 'folder'|trans }}">20 -1 <a href="?path=_uploads{{ file.path }}" class="file-list__main">{{ file.name }}/</a>21 24 {% endif %} 22 25 </li> 23 26 {% endfor %}