EDITED. index.html을 내부질문을 명확히하기 위해 메인 HTML에 변수를 전달하는 파일 업로드 양식
- 파일 업로드 양식을 :
어디 싶어. (완료)
- 양식이 PHP 파일로 제출됩니다. (완료)
- PHP 파일은 파일을 올바른 위치로 이동시킵니다. (완료)
- index.html이 다시로드되고 PHP가 종료되었습니다. (done)
- index.html은 나중에 PHP를 사용하기 위해 업로드 된 파일의 위치를 가져옵니다. 내가 다시 index.html을에 PHP에서 매개 변수를 제공하거나 문제가 이해가 안 방법 (취소)
나도 몰라, 어떻게 PHP와 HTML 정보를 교환한다.
그래서 이런 종류의 기능이 Ajax로 작성 될 수 있으므로 index.html을 "나갈 필요가 없습니다."
내 HTML 내부에이 양식이 있습니다
<form method="post" enctype="multipart/form-data" action="uploader.php">
<input type="file" name="uploadedfile"/>
<input type="submit" name="submit" class="button" value="Submit"></button>
</form>
을 그리고 그것은 호출하는 PHP는 다음과 같습니다
<?php
$target_path = "uploads/";
$target_path = $target_path . ($_FILES["uploadedfile"]["name"]);
if(move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], $target_path)) {
echo "Success!"
} else{
echo "There was an error uploading the file, please try again!";
}
header('Location: http://localhost/index.html');
exit();
?>
제출 누른 후 파일이 제대로 서버에 업로드됩니다.
질문을 명확히 할 수 있습니까? – svinto
코일 타입의 질문입니다 – leon
명확하게하지 않으면 질문이 닫힙니다. – Nasreddine