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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.