내 양식이 간단하고 업로드 PHP가 간단하다고 생각했지만 테스트 할 때 결과가 비정상적입니다. 나는 어떤 파일든지 어떤 크기든지 올려주기 할 수 있고 일할 것이다. 나는 그것이 특정 파일과 크기를 제한하기 위해 작성했다고 생각했는데 ... 어디가 잘못 되었나요?업 로더 파일 업로드 내용
형태 :
<form enctype="multipart/form-data" action="upload_file.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
upload_file.php :
$target = "uploads/";
$target = $target . basename($_FILES['uploaded']['name']) ;
$ok = 1;
$uploaded = $_POST['uploaded'];
//This is our size condition
if ($uploaded_size > 3000){
echo "Your file is too large.<br>";
$ok=0;
}
//This is our limit file type condition
if ($uploaded_type == "text/php"){
echo "No PHP files are allowed for upload.<br>";
$ok = 0;
}
//Here we check that $ok was not set to 0 by an error
if ($ok == 0){
Echo "Sorry your file was not uploaded";
}
//If everything is ok we try to upload it
else{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)){
echo "The file ". basename($_FILES['uploadedfile']['name']). " has been uploaded";
}
else{
echo "Sorry, there was a problem uploading your file.";
}
}
어디에 $ uploaded_type 및 $ uploaded_size var입니까? – Yordi
여기에 정말 간단 명료 한 기사입니다. http://www.w3schools.com/php/php_file_upload.asp – Vector
@Vector : 아뇨, w3schools.com을 참고로 사용하지 마십시오. 오류가 많습니다. http://w3fools.com –