Forum


Replies: 5   Views: 3950
Deleting tmp files?
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by Squad internet  · 11-04-2013 - 12:13

require_once('/var/www/Core/0.1/Includes/phpdocx/classes/CreateDocx.inc');
class Tools_Docx extends createDocx{


/**
* Delete all tempfiles.
* MAKE SURE YOU USE A SEPATE DIRECTORY FOR PHPDOCX IN YOUR /TMP DIR!!!!
* This will DELETE all files in the directory you passed in the constructor!!!!
*
*/
public function cleanUp(){
$this->_recurseDelete($this->getTemporaryDirectory());
}

private function _recurseDelete($path){
if(is_dir($path)){
$dirs=scandir($path);
$c=count($dirs);
for($i=0;$i<$c;$i++){
if($dirs[$i]!='.'&&$dirs[$i]!='..'){
$this->_recurseDelete($path . DIRECTORY_SEPARATOR . $dirs[$i]);
}
}
if($path!=$this->getTemporaryDirectory()){
rmdir($path);
}
}else{
unlink($path);
}
}
}