Welcome Guest, Not a member yet? Register   Sign In
File in use?

I have this code to upload a zip file and then immediately to unzip it. If the operation fail because in the directory does not have any css files or the template file does not exist I call the function deleteDir to delete what was extracted from the zip file. Normally in my Web FileManager application is deleting all Files and Folders the deleteDir function but here because I am calling the get_filenames function PHP returns that the directory is not empty. When I do not call that function it deletes everything. It seems like the directory is in use by the get_filenames so it cannot remove it Sad.

I think the same thing is happening also when I try to unlink the zip file. I get the error permission denied.
If I use my Web Filemanager to delete the zip everything is working normally.

Any ideas how to solve this?

$data = $this->upload->data();
            $config['fileName']  = $data['file_path'].$data['file_name'];
            $config['targetDir'] = $data['file_path'];
            $css = get_filenames($data['file_path'].$data['raw_name'].'/css/');
            if (!file_exists($data['file_path'].$data['raw_name'].'/template.tpl') || (empty($css))) {


function deleteDir($dir) {
        $dir_content = scandir ($dir);
        if ($dir_content !== FALSE) {
            foreach ($dir_content as $entry)
                if (!in_array($entry, array ('.','..'))){
                    $entry = $dir. '/'. $entry;
                    if (!is_dir($entry)) {
                    else {
            rmdir ($dir);
            return true;

Messages In This Thread
File in use? - by El Forum - 11-21-2008, 05:23 AM
File in use? - by El Forum - 11-21-2008, 05:47 AM

Theme © iAndrew 2016 - Forum software by © MyBB