Jump to content

Why is this deleting folder when it contains something?


dc_jt

Recommended Posts

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());
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.