0
첫 번째 양식/파일 업 로더를 만들려고합니다 (저는 newb fyi입니다).양식에 파일 업 로더가 보이지 않습니다 - ph
내 Mac의 로컬 서버에서 테스트 중이며, 양식, 파일 처리기 및 업로드 폴더는 모두 동일한 파일 디렉토리에 있습니다.
제출 양식 (테스트 파일은 'testFilego.txt'이고 크기가 3 바이트 임)을 사용하여 파일을 선택하면 다음 오류가 발생합니다 : http://localhost/PhP_exercises/__tizag/280-php-fileupload-test.php?MAX_FILE_SIZE=2500000&uploadedfile=testFilego.txt
. 제출 양식이 처리기 (?)에 연결하지 않는 것 같습니다. 테스트 파일이 내 업로드 폴더에 나타날 것이라고 생각했습니다. 도움.
이
가 제출 형태 :이 파일이 양식을 투수한다고한다<form>
<form enctype="multipart/form-data" action="280-php-uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="2500000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</form>
마르코 Acierno가 관찰
<?php
280-php-uploader.php<?php
//This is '280-php-uploader.php'
// Where the file is going to be placed
$target_path = "uploads/";
// Add the original filename to our target path.
//Result is "uploads/filename.extension"
$target_path = $target_path . basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename($_FILES['uploadedfile']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
양식을 양식에 넣는 이유는 무엇입니까? 어쩌면 이것이 문제 일 수 있습니다. 먼저
그건 문제가 된 것 같습니다. 나는 폼 안에 폼이 있다는 것을 보지 못했고, 따라서 폼 자체에 포스팅하고 있었다. 당신의 예리한 눈을 위해 Marco에게 감사드립니다! – Chezshire