зеркало из https://github.com/nextcloud/server.git
implemented deleting multiple files
This commit is contained in:
Родитель
ca00d37a71
Коммит
5a11e739b4
|
@ -14,14 +14,23 @@ if( !OC_USER::isLoggedIn()){
|
|||
|
||||
// Get data
|
||||
$dir = $_GET["dir"];
|
||||
$file = $_GET["file"];
|
||||
$files = isset($_GET["file"]) ? $_GET["file"] : $_GET["files"];
|
||||
|
||||
// Delete
|
||||
if( OC_FILES::delete( $dir, $file )){
|
||||
echo json_encode( array( "status" => "success", "data" => array( "dir" => $dir, "file" => $file )));
|
||||
$files = explode(';', $files);
|
||||
$filesWithError = '';
|
||||
$status = 'success';
|
||||
//Now delete
|
||||
foreach($files as $file) {
|
||||
if( !OC_FILES::delete( $dir, $file )){
|
||||
$filesWithError .= $file . "\n";
|
||||
$status = 'error';
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to delete file" )));
|
||||
|
||||
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 )));
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -113,6 +113,25 @@ $(document).ready(function() {
|
|||
window.location='ajax/download.php?files='+files+'&dir='+dir;
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.delete').click(function(event) {
|
||||
var files='';
|
||||
$('td.selection input:checkbox:checked').parent().parent().children('.filename').each(function(i,element){
|
||||
files+=';'+$(element).text();
|
||||
});
|
||||
files=files.substr(1);//remove leading ;
|
||||
|
||||
//send the browser to the download location
|
||||
$.ajax({
|
||||
url: 'ajax/delete.php',
|
||||
data: "dir="+$('#dir').val()+"&files="+files,
|
||||
complete: function(data){
|
||||
boolOperationFinished(data, false);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
function uploadFinished() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче