I am using the ezcomponents archive component to extract uploaded files that is being uploaded to my website. The extracting part is very easy but how do I specifically assign the right permissions to those files being extracted?
http://ezcomponents.org/docs/tutorials/Archive#usage
$extract_dir = 'some existing directory';
$archive = ezcArchive::open($file, ezcArchive::ZIP);
while( $archive->valid() )
{
if ( is_dir($extract_dir) === false )
{
@mkdir($extract_dir, 0777);
}
// Extract the current archive entry to /data/<issue_id>/
$archive->extractCurrent($extract_dir);
$archive->next();
}
Regards
Do a recursive chmod on the directory. (Use this, if you don't find a built in functionality in ezcomponents)
<?php
function chmodr($path, $filemode) {
if (!is_dir($path))
return chmod($path, $filemode);
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
if($file != '.' && $file != '..') {
$fullpath = $path.'/'.$file;
if(is_link($fullpath))
return FALSE;
elseif(!is_dir($fullpath) && !chmod($fullpath, $filemode))
return FALSE;
elseif(!chmodr($fullpath, $filemode))
return FALSE;
}
}
closedir($dh);
if(chmod($path, $filemode))
return TRUE;
else
return FALSE;
}
?>