delete.php 868 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. // Init owncloud
  3. OCP\JSON::checkLoggedIn();
  4. OCP\JSON::callCheck();
  5. // Get data
  6. $dir = stripslashes($_POST["dir"]);
  7. $files = isset($_POST["file"]) ? $_POST["file"] : $_POST["files"];
  8. $files = json_decode($files);
  9. $filesWithError = '';
  10. $success = true;
  11. //Now delete
  12. foreach ($files as $file) {
  13. if (($dir === '' && $file === 'Shared') || !\OC\Files\Filesystem::unlink($dir . '/' . $file)) {
  14. $filesWithError .= $file . "\n";
  15. $success = false;
  16. }
  17. }
  18. // get array with updated storage stats (e.g. max file size) after upload
  19. $storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir);
  20. if ($success) {
  21. OCP\JSON::success(array("data" => array_merge(array("dir" => $dir, "files" => $files), $storageStats)));
  22. } else {
  23. OCP\JSON::error(array("data" => array_merge(array("message" => "Could not delete:\n" . $filesWithError), $storageStats)));
  24. }