tags:

views:

38

answers:

1

hi guys, i wonder if theres a tutorial out there or you could give me a quick and simple approach how i could do the following task.

i have a folder on my server. i want to build a kind of cms where i can easily delete files from a folder. i know how to upload them, i already found a tutorial.

i think of simply running through all files, creating a list of them with a checkbox in front, selecting the checkbox and pressing a DELETE button.

is this a rather difficult task to get done? do you maybe kno any tutorial or something.

thank you very much!

+1  A: 

Start with List all files

<?php
    // file_array() by Jamon Holmgren. Exclude files by putting them in the $exclude
    // string separated by pipes. Returns an array with filenames as strings.
    function file_array($path, $exclude = ".|..", $recursive = false) {
        $path = rtrim($path, "/") . "/";
        $folder_handle = opendir($path);
        $exclude_array = explode("|", $exclude);
        $result = array();
        while(false !== ($filename = readdir($folder_handle))) {
            if(!in_array(strtolower($filename), $exclude_array)) {
                if(is_dir($path . $filename . "/")) {
                    if($recursive) $result[] = file_array($path, $exclude, true);
                } else {
                    $result[] = $filename;
                }
            }
        }
        return $result;
    }
?>

then create hyperlinks to the above files to a delete function like;

unlink('filename.jpg');
Adnan