dc_jt Posted May 22, 2007 Share Posted May 22, 2007 Hi Ive got the following which is meant to delte the may2007 folder if there is nothing inside of it. The only types of file it holds is .doc and .pdf. When I put one of each in there and I delete the .pdf, then this deletes just that and nothing else which is correct because there is still another document (the .doc one) in the folder. However, if I put both in and I delete the .doc one first, then this deletes the whole folder (may2007) when it shouldnt because there is another file in there (the .pdf one). Hope that wasnt too confusing and someone can help. Thanks public function RemoveDownload($iNewsId) { $oDownload = $this->GetObject($iNewsId); if ($oDownload->download) { unlink($_SERVER['DOCUMENT_ROOT'].UPLOADS_FOLDER_DOWNLOAD.$oDownload->download_path.'/'.$oDownload->download); $files = glob($_SERVER['DOCUMENT_ROOT'].UPLOADS_FOLDER_DOWNLOAD.$oDownload->download_path.'/{*.doc, *.pdf, *.DOC, *.PDF}', GLOB_BRACE);//Makes sure that it contains no Image if(count($files) < 1) { $oDeleteFolder = $this->removeFolder($_SERVER['DOCUMENT_ROOT'].UPLOADS_FOLDER_DOWNLOAD.$oDownload->download_path); } } $sSql = "UPDATE $this->sTableName SET download = '', download_path = '' WHERE $this->sPrimaryKey = '$iNewsId' "; return mysql_query($sSql, $this->oDb->GetConnection()); } Quote Link to comment https://forums.phpfreaks.com/topic/52482-why-is-this-deleting-folder-when-it-contains-something/ Share on other sites More sharing options...
dc_jt Posted May 22, 2007 Author Share Posted May 22, 2007 Anyone??? Quote Link to comment https://forums.phpfreaks.com/topic/52482-why-is-this-deleting-folder-when-it-contains-something/#findComment-258998 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.