Blame view
sources/apps/files/ajax/delete.php
1.15 KB
|
03e52840d
|
1 |
<?php |
|
03e52840d
|
2 3 |
OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); |
|
6d9380f96
|
4 |
\OC::$session->close(); |
|
03e52840d
|
5 6 7 |
// Get data $dir = stripslashes($_POST["dir"]); |
|
6d9380f96
|
8 9 10 11 12 13 14 15 16 17 18 19 20 |
$allFiles = isset($_POST["allfiles"]) ? $_POST["allfiles"] : false;
// delete all files in dir ?
if ($allFiles === 'true') {
$files = array();
$fileList = \OC\Files\Filesystem::getDirectoryContent($dir);
foreach ($fileList as $fileInfo) {
$files[] = $fileInfo['name'];
}
} else {
$files = isset($_POST["file"]) ? $_POST["file"] : $_POST["files"];
$files = json_decode($files);
}
|
|
03e52840d
|
21 22 23 24 25 26 |
$filesWithError = '';
$success = true;
//Now delete
foreach ($files as $file) {
|
|
f7d878ff1
|
27 28 |
if (\OC\Files\Filesystem::file_exists($dir . '/' . $file) &&
!\OC\Files\Filesystem::unlink($dir . '/' . $file)) {
|
|
03e52840d
|
29 30 31 32 33 34 35 |
$filesWithError .= $file . " "; $success = false; } } // get array with updated storage stats (e.g. max file size) after upload |
|
31b7f2792
|
36 |
$storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir); |
|
03e52840d
|
37 38 39 40 41 42 43 |
if ($success) {
OCP\JSON::success(array("data" => array_merge(array("dir" => $dir, "files" => $files), $storageStats)));
} else {
OCP\JSON::error(array("data" => array_merge(array("message" => "Could not delete:
" . $filesWithError), $storageStats)));
}
|