질문Q #3022
chmod를 사용하려면 어떻게 해야하나요
rhe2014-12-29 13:02:54
뜬금없는 질문드려 죄송합니다.
write_file(); 함수를 사용하기 전에 해당 파일의 권한을 644에서 707로 바꾸어서 함수를 사용하고 다시 644로 바꾸어주고 싶습니다.
그런데 여기저기 찾아보아도 알수가 없어서 이렇게 글을 올립니다.
@chmod($file, 0707);
이렇게 하면 사용할 수 없다고 나오는데요
코드이그나이트에서도 이걸 사용할 수 있을거라는 생각은 드는데 어찌해야할지 잘 몰라서....
양승현님 Tip을 참고해도 $common 에러발생하고
나름대로 이틀을 이리저리 헤메다 도저히 안돼겠다 싶어 글 올립니다.
/**
* 하뒤 디렉토리 파일까지 퍼미션 지정
*
* @param String $path : 디렉토리
* @param int $filemode : 퍼미션 값
*/
function chmodr($path, $filemode) {
$CI =& get_instance();
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(!$CI->common->chmodr($fullpath, $filemode))
return FALSE;
}
}
closedir($dh);
if(chmod($path, $filemode))
return TRUE;
else
return FALSE;
}
게시판이동합니다.