상당히 간단한 (이론적으로) 파일 업로드 '프로세스'를 만들려고합니다. 나는 사이트를 빠져 나갔고, 내가 필요로하는 부분이 있지만 아무것도 작동하지 않는 것 같다!파일 업로드/mkdir() 문제
- 가져 오기 파일 확장자
- 가져 오기 파일 이름
- 결합 파일 이름, 클라이언트 ID 및 확장
- 확인 대상이 그 :
기본적으로, 다음과 같이 처리하는 함수를 작성하는 것을 시도하고있다 디렉토리가 존재합니다. 그렇지 않다면 생성하십시오.
- 루트
- 관리자
- 업로드
- client_uploads을 : 다음과 같이
- 업로드
- 관리자
- 루트
내 파일 구조가있는 디렉토리로 (새로운 이름 아래) 파일을 이동
-
0 내가 명시 적으로 요청했습니다 있지만
<?php
include("dbconnect.php");
error_reporting(-1); // ALL messages and
ini_set('display_errors', 'On');
if($_GET['clientID']){
//This function separates the extension from the rest of the file name and returns it
function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
//Get filename function
$filename = "test"; //I dont know how to create this function at the moment
return $filename;
//This applies the function to our file
$ext = findexts ($_FILES['uploaded']['name']) ;
// we will be using the clientID as the new folder and adding it into the filename
$clientID = mysql_real_escape_string((int)$_GET['clientID']);
//merge filename
$filename2 = $filename."_".$clientID.".";
//Scan for existing directory
$folder = '../admin/uploads/client_uploads/'.$username.'/';
if (is_dir("$folder") == false) {
mkdir("$folder", 0777);
echo "Directory created";
}
//This assigns the subdirectory you want to save into... make sure it exists!
$target = "admin/client_uploads/$clientID";
//This combines the directory, the random file name, and the extension
$target = $target . $filename2.$ext;
//Move file under new name
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file has been uploaded as ".$filename2.$ext;
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>
내가 (오류 메시지를받지 못했습니다 :
내가 가진 무엇을 된 ClientID 그들) 그리고 나는 단지 빈 화면으로 끝난다. 폴더가 내 서버의 아무 곳에도 생성되지 않으며 아무 것도 발생하지 않습니다.
아이디어가 있으십니까? 미리 감사드립니다.
PHP 오류 로그에서 메시지를 확인 했습니까? 섹션을 주석 처리하고 개별 변수를 'var_dump'하여 단계별로 디버깅하려 했습니까? – deceze
내 오류 로그를 확인하는 방법을 모릅니다. 코드의 첫 번째 줄마다 페이지에 오류가 표시되었을 것입니다. – Anthony
'split'명령에 오류가있는 것처럼 보입니다. 나는 그것의 장소에있는 '폭발하는'카 몬드 또는 어떤 것을 사용해야합니까? – Anthony