------------------------ When the admin access the upload form ------------------------ //get list of files for all zones as this is admin side $uploadedFiles=$FileLister->getFileList(range(1,somenumberX)); ------------------------ Posting the form ------------------------ //now record all the zones associated with this file $postInfo['zone']=@array_unique($postInfo['zone']); foreach((array)$postInfo['zone'] as $z) dbQuery("insert into sometablename (fui_ZoneID,fui_FileID) values (".(int)$z.",{$retID})"); return $this->moveUploadedFile($retID,$fileInfo); } function moveUploadedFile($dbID,$fileInfo){ if(!$fileInfo['name'] || !$fileInfo['tmp_name']) return false; //create path where the file will be saved @mkdir($this->savePathDir.'/'.$dbID,0700); $newPath=$this->savePathDir.'/'.$dbID.'/'.$fileInfo['name']; //save the file return rename($fileInfo['tmp_name'],$newPath) ? $newPath: false; } ----------------------- foreach($_POST_DATA as $k=>$v){ if(substr($k,0,somenumberX)=='zone'){ unset($_POST_DATA[$k]); $_POST_DATA['zone'][]=(int)$k[somenumberX]; } elseif(!is_array($v)) $_POST_DATA[$k]=addslashes($v); } ------------------------ When the authorized user accesses the documents ------------------------ function getZonesForUser($userID) { $sqlp = "SELECT * from sometablename WHERE fui_UserID = $userID"; $result = dbQuery($sqlp); $ret=array(); while($r=mysql_fetch_assoc($result)) $ret[]=$r['fui_ZoneID']; return $ret; }