입니다. 귀찮은 문제가 발생했습니다. method = "post"를 사용하여 다음 코드를 제출하고 $ _POST 변수를 찾으면 코드가이를 인식하지 못합니다. method = "get"으로 전환하고 $ _GET 변수를 찾으면 정상적으로 작동합니다. Get을 사용하지 않는 것을 선호합니다. 어떤 제안? 내 마지막 코드에는 다른 입력도 포함되지만, 파일 입력을 선택적으로하고 싶습니다. 따라서 파일 입력이 실제로 전송 된 경우에만 코드를 처리해야합니다. 당신의 도움을 주셔서 감사합니다!
//form.html.php
<form action="index.php" method="post" enctype="multipart/form-data">
<label id="upload">Select file to upload:
<input type="file" id="upload" name="foobar" /></label>
<input type="submit" value="Submit" />
</form>
//index.php
if(isset($_POST['foobar']))
{
//some code
}
그러나이 파일을 얻으려면
//form.html.php
<form action="index.php" method="get" enctype="multipart/form-data">
<label id="upload">Select file to upload:
<input type="file" id="upload" name="foobar" /></label>
<input type="submit" value="Submit" />
</form>
//index.php
if(isset($_GET['foobar']))
{
//some code
}
밖으로 코드. 그게 효과가 있었어. 감사! – TimSum
isset ($ _ FILES [ 'foobar']) 파일이 업로드되었는지 여부에 관계없이 true를 반환 했으므로 if (isset ($ _ FILES [ 'foobar']) 및 $ _FILES [ 'foobar'] [ 'name' ]! = "") – TimSum