내 업로드 폴더로 전송하는 파일이 정상적으로 작동하지만 mkdir에 경고가 표시됩니다. 그것은 파일은 존재하지만 그림과 폴더는 자신의 이름을 생성합니다. 나는 어떤 경고가 나오는지 모른다.경고 : mkdir() : 파일이 있습니다.
누구든지 나를 도와 줄 수 있습니까?
include('connect.php');
$dir=substr(uniqid(),-7); // Uniqid for subdirectory
$path = "uploads/$dir/"; // uploads/subdirectory/ // Make directory
$valid_formats = array("jpg", "png", "jpeg", "kml");
$max_file_size = 2097152;
$count = 0;
// Loop $_FILES to execute all files
if(!empty($_FILES)){
foreach($_FILES['files']['name'] as $f => $name) {
if ($_FILES['files']['error'][$f] == 4) {
continue; // Skip file if any error found
}
if ($_FILES['files']['error'][$f] == 0) {
if ($_FILES['files']['size'][$f] > $max_file_size) {
$message[] = "$name is too large!.";
continue; // Skip large files
}
elseif(! in_array(pathinfo($name, PATHINFO_EXTENSION), $valid_formats)){
$message[] = "$name is not a valid format";
continue; // Skip invalid file formats
}
else{ // No error found! Move uploaded files
mkdir($path, 0700);
$ext = pathinfo($_FILES['files']['name'][$f], PATHINFO_EXTENSION);
$uniq_name = substr(uniqid(),-5) . '.' .$ext;
$dest = $path . $uniq_name;
if(move_uploaded_file($_FILES["files"]["tmp_name"][$f], $dest)){
$qry = "INSERT INTO files (code, name, path, type) VALUES ('$dir','$uniq_name','$dest','$ext')" ;
$result = mysqli_query($dbc, $qry);
if (false===$result) {
$sql_error .= 'Error in the query '.$qry.' Error Desc :'.mysqli_error($dbc).'<br /><br />' ;
}
}
}
}
}}
내가 사용하는 경우 {에서 mkdir ($ 경로, 0700) (file_exists ($ 경로)!); }하지만 여러 장을 업로드했지만 한 장의 사진 만 업로드합니다. 나는 어떻게해야합니까? 미안 해요. 문법. 이것은 제 첫 언어가 아닙니다. – clien
파일 이름에서 폴더 경로를 구분해야합니다. @ user3199128 – Erik