nextcloud/files/ajax/delete.php

37 lines
889 B
PHP
Raw Normal View History

<?php
// Init owncloud
require_once('../../lib/base.php');
// We send json data
header( "Content-Type: application/jsonrequest" );
// Check if we are a user
2011-07-29 23:36:03 +04:00
if( !OC_User::isLoggedIn()){
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
exit();
}
// Get data
$dir = $_GET["dir"];
2011-04-18 18:48:35 +04:00
$files = isset($_GET["file"]) ? $_GET["file"] : $_GET["files"];
2011-04-18 18:48:35 +04:00
$files = explode(';', $files);
$filesWithError = '';
$status = 'success';
//Now delete
foreach($files as $file) {
2011-07-29 23:36:03 +04:00
if( !OC_Files::delete( $dir, $file )){
2011-04-18 18:48:35 +04:00
$filesWithError .= $file . "\n";
$status = 'error';
}
}
2011-04-18 18:48:35 +04:00
if($status == 'success') {
echo json_encode( array( "status" => $status, "data" => array( "dir" => $dir, "files" => $files )));
} else {
echo json_encode( array( "status" => $status, "data" => array( "message" => "Could not delete:\n" . $filesWithError )));
}
?>