Welcome Guest, Not a member yet? Register   Sign In
delete_files() not working correctly in CI3
#1

This call is not working correctly. I'd like to delete uploads/richb2-gmail-com/ and all its subdirs. This my structure
uploads/richb2-gmail-com/thumbnails

        $szBucket_name = str_replace(array("@", "."), "-", $_SESSION['userid']);
        $ouputDirectory = '/app/assets/uploads/'.$szBucket_name.'/';
        delete_files($ouputDirectory,TRUE);   << $outputDirectory is 

/app/assets/uploads/richb201-gmail-com/
But when this runs it only deletes the following dir and it's files. It skips deleting /richb201-gmail-com
/app/assets/uploads/richb201-gmail-com/thumbnails
proof that an old dog can learn new tricks
Reply
#2

[quote pid="389060" dateline="1627916219"]
 i use to for ci3 ,4 

PHP Code:
<?php namespace Modules\Common\Libraries;

use 
CodeIgniter\HTTP\Response;

class  CustomFileSystem
{
    protected string $error;

    public function __construct()
    {
        $this->error '';
    }

    /**
    * @return string
    */
    public function getError(): string
    
{
        return $this->error;
    }

    public function removeSingleFile($path)
    {
        try {

            if (file_exists($path)) {
                unlink($path);
            }


        } catch (\Exception $e) {
            $this->error $e->getMessage();

        }

    }


    public function removeMultipleFiles($path)
    {
        try {

            if (file_exists($path)) {
                unlink($path);
            }


        } catch (\Exception $e) {
            $this->error $e->getMessage();

        }

    }




[/quote]
Enlightenment  Is  Freedom
Reply
#3

Delete ALL Files and Subfolders from Folder in PHP
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

Thanks. I got that working now. My only problem is if the user exits the window by using X, my delete code doesn't run. Is there anyway to catch that a user is exiting via X ?
proof that an old dog can learn new tricks
Reply
#5

How to capture the browser window close event?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

(This post was last modified: 08-05-2021, 08:47 AM by richb201.)

Thanks I will review that.
proof that an old dog can learn new tricks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB