-4
시스템의 업로드 된 파일에서 대괄호를 제거하는 데 문제가 있습니다.PHP : 디렉토리 및 모든 하위 디렉토리의 파일 이름에서 대괄호를 재귀 적으로 제거합니다.
단일 디렉토리의 파일에서 대괄호를 제거 할 수 있지만 같은 폴더의 하위 디렉토리에서이 작업을 재귀 적으로 처리하는 데 어려움을 겪고 있습니다.
대괄호 []를 찾고 공백 문자로 바꾸려면 str_replace를 사용하고 있습니다. 좋아
$dir = $_SERVER["DOCUMENT_ROOT"]."/uploads" ; // what directory to parse
if ($handle = opendir ($dir)) {
print "Directory Handle = $handles\n" ;
print "Files : \n" ;
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$isdir = is_dir ($file) ;
if ($isdir == "1") {} // if its a directory do nothing
else {
$file_array[] = "$file" ; // get all the file names and put them in an array
print "$file\n" ;
} // closes else
} // closes directory check
} // closes while
} // closes opendir
//Lets go through the array
$arr_count = count($file_array) ; // find out how many files we have found so we can initiliase the counter
for ($counter=1; $counter<$arr_count; $counter++) {
print "Array = $file_array[$counter]\n" ; // tell me how many files there are
$illegals = array("[","]");
$new = str_replace ($illegals, "", $file_array[$counter]) ; // now create the new file name
$ren = rename ("$dir/$file_array[$counter]" , "$dir/$new") ; // now do the actual file rename
print "$new\n" ; // print out the new file name
}
closedir ($handle) ;
echo $dir;
"코드를 찾을 수 없지만 나중에 업로드 할 것입니다." 좋아, 그럼 기다릴게 ... – nogad
[PHP : 모든 파일의 이름을 소문자로 재귀 적으로 이름을 바꿀 수 있음] (https://stackoverflow.com/questions/32173320/php-rename-all-files-to) -lower-case-in-a-directory-recursively) – Nic3500
코드를 즉시 업로드하지 않으셔서 죄송합니다. 그것은 벌써 2am이었다. 그리고 나의 gf는 나에게 고함을 지르고 있었다. 하루 종일이 작업을 수행하는 방법을 찾으려고했습니다. – feratechinc