How i can delete user private files, and where in db save links for uploaded userfiles

How i can delete user private files, and where in db save links for uploaded userfiles

by Андрей Горюшкин -
Number of replies: 1

Need function that allows delete several files from users.

What API function can help me? 

Need algorithm ...



Average of ratings: -
In reply to Андрей Горюшкин

Re: How i can delete user private files, and where in db save links for uploaded userfiles

by Андрей Горюшкин -

if some interested of this ->


<?php


/**

 * @author InQaaaa

 * @copyright 2016

 */

 

require("config.php");


$userid = $_GET['userid'];

$filename = $_GET['filename'];


//Get id of file

$table = "files";

$select = "filename = '$filename' AND userid = '$userid' AND filearea='private'";

$result = $DB->get_records_select($table, $select);


//Some manipultaion with stdObject

$array = json_decode(json_encode($result), True);

$array1 = array_shift($array);

$idd = $array1["id"];



// Delete it if it exists

$file = $fs->get_file_by_id($idd);


if ($file) {

    $file->delete();

}




?>