이것이 작동하지 않는 이유를 모르겠습니다. 그것은 아주 쉬워야합니다.PHP - 파일 업로드 실패
upload.php로 :
$uploaddir = '/usr/share/nginx/www/pitfax/upload/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo "<p>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
}
else {
echo "Upload failed";
}
echo "</p>";
echo '<pre>';
echo 'Here is some more debugging info:';
print_r($_FILES); print "</pre>";
폼 페이지 :
가<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
오류 출력된다 :
Upload failed
Here is some more debugging info:Array (
[userfile] => Array
(
[name] => test.pdf
[type] => application/pdf
[tmp_name] => /tmp/phptM0p4w
[error] => 0
[size] => 1287464
)
)
- 웹 서버 :,745,151 Nginx에
- 권한 :
upload
디렉토리 (644) - 권한 : 755
- 을 루트 사용자와 SSH에서 작업.
- 편집 :이 upload_max_filesize = 2M
- 편집 : post_max_size을 = 8M
upload.php
에 대한
또 한가지! 업로드가 완료되면 업로드 된 파일의 절대 경로를 가져오고 싶습니다. (예 : /usr/share/nginx/www/pitfax/upload/test.pdf
)
오류 로그에는 무엇이 있습니까? – zerkms
업로드 디렉토리를 777로 설정해 보셨습니까? –
@LukePittman 예, 작동하지 않았습니다. – xperator