Directory

Copy, Move, Kill

copy($source,$destination);
unlink($source);
rename($oldfile,$newfile);
from MenuCreat.php_________________
$whichfile is the tempalte number
if($createfile==true && strpos($file0,"ttp://")==0){
        
        $fnd=strpos($file0,"?");
        if($fnd>0)$file0=substr($file0,0,$fnd);
        if(!file_exists($destinationfolder.$file0)){
            //echo "==".$destinationfolder.$menu[$K][1]."<br>";
            copy($templatefolder.$template.$whichfile.".php",$destinationfolder.$file0);
        }
    }

Directory

[top dir]
dirname(__FILE__)
mkdir('/home/benge/photos/gallery1/extra_large', 0777);
Check for existence
if(is_dir($dirname))
[working directory]
if($ID==""){
    $dir1=getcwd();$k=1;
    while ($k>0){
        $k1=$k;
        $k=strpos($dir1,"/",$k+1);
    }
    $dir1=substr($dir1,$k1+1,strlen($dir1)-$k1);
    $sql="SELECT userid FROM users WHERE userpath='$dir1'";
    $row9=dbq($sql,$num,1,3);
    $HTTP_SESSION_VARS['USERID']=$row9;$ID=$row9;
}

Downloads

if(is_dir($folder2)==false) { mkdir($folder2);copy($folder1."/".$book,$folder2."/".$book); }
    $filesize=filesize($folder2."/".$book);
        header("Pragma: public");
      header("Expires: 0");
      header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
      header("Cache-Control: private",false);
      header ( "Content-Type: application/pdf" );
      header("Content-Disposition: attachment; filename=\"$booktitle\";");
      header("Content-Transfer-Encoding:­ binary");
      header("Content-Length: ".$filesize);
    $file=$folder2."/".$book;
  readfile($file);

Exists

if(file_exists($upfile))unlink($upfile);

Read Directory

$imagedirectory="../banners/";
[Create image viewer]
<?php
$imagedirectory="../stylists/";
$dir = opendir($imagedirectory);
while ($file = readdir($dir)){
//for ($i=1; $i<=500; $i++){
//   $file = readdir($dir);
    $fullpath=$current_dir.$file;
    /*
    $filedate=date('Y-m-j', filemtime($fullpath));
    if(trim($file)!='.' && trim($file)!='..'){
        $fsize=filesize($fullpath)/1000;
        $fsize=(int)$fsize;$fsize=$fsize/1000;
        $message[]=$filedate."|".$file."@".$fsize;
    }
    */
    echo "<div style='float:left;padding:20px;'><img src='$fullpath'><br>$file</div>";
}
  closedir($dir);
?>
=====================

$dir = opendir($imagedirectory);
while ($file = readdir($dir)){
    if(strpos($file,".")!=0){
        $file1.=chr(34).$file.chr(34).",";$file2.=chr(34).chr(34).",";
    }
}
==================================================

while ($file = readdir($dir)){
//for ($i=1; $i<=500; $i++){
//   $file = readdir($dir);
    $fullpath=$current_dir.$file;
    $filedate=date('Y-m-j', filemtime($fullpath));
    if(trim($file)!='.' && trim($file)!='..'){
        $fsize=filesize($fullpath)/1000;
        $fsize=(int)$fsize;$fsize=$fsize/1000;
        $message[]=$filedate."|".$file."@".$fsize;
    }
}
  closedir($dir);