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
You can use a callback for every extracted file/directory, in order to set the desired permissions. You specify the callback through the ezcArchiveOptions.
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;
}
?>
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论