Deleting folders and their content. |
Hi,
I'm having problems when it comes to deleting specific folders. All folders get deleted inside an "uploads" folder when I only want a single folder deleted. My application allows new companies to register on the system. When a company registers a new folder gets created inside the uploads folder specific to that company (a random md5 string is used). My folder setup: - public_html / htdocs - uploads - 731e315adc887be41cc84be0f5c73f76 - avatars - b8218d22eaaca5deb91c741c4d7112dd - 71913f59e458e026d6609cdb5a7cc53d - etc... In the app I provide admins the ability to delete companies. When a company is being deleted I want all files & subfolders inside the company specific folder deleted and then the folder itself. The md5 string is stored in a MySQL database (as 'uploads_folder') along with other info about the company. In the delete function in the Companies class I get the company info using the following: PHP Code: $company_folder = $this->company_lib->get_uploads_folder($id); The get_uploads_folder function inside the Company_lib library simply returns the full path: PHP Code: public function get_uploads_folder($company_id) I then load the file helper and call the delete_files function: PHP Code: $this->load->helper('file'); When the delete_files function runs it deletes all folders inside the uploads folder instead of just deleting the one specific to that company. What am I doing wrong? By the way this is happening when using WAMP on my windows computer. I haven't tested it on my host yet (which uses Unix/Linux) for fear of deleting even more folders! |
Messages In This Thread |
Deleting folders and their content. - by keithmclaughlin - 04-20-2017, 09:08 AM
RE: Deleting folders and their content. - by dave friend - 04-20-2017, 12:39 PM
RE: Deleting folders and their content. - by Rufnex - 04-20-2017, 12:44 PM
RE: Deleting folders and their content. - by dave friend - 04-20-2017, 12:51 PM
RE: Deleting folders and their content. - by Rufnex - 04-20-2017, 02:27 PM
RE: Deleting folders and their content. - by keithmclaughlin - 04-21-2017, 03:55 AM
RE: Deleting folders and their content. - by Rufnex - 04-21-2017, 01:55 PM
RE: Deleting folders and their content. - by keithmclaughlin - 04-22-2017, 05:39 AM
RE: Deleting folders and their content. - by Rufnex - 04-23-2017, 10:39 AM
RE: Deleting folders and their content. - by keithmclaughlin - 04-24-2017, 07:07 AM
|