この質問をして、答えを得られない人がたくさんいるようです。フォームのファイル アップロード部分が入力されているかどうかの確認に問題はありますか? これはグローバル変数であり、常に設定されているためですか?
私が抱えている問題は、ファイル入力ytpeが入力されているかどうかを確認することです。
以下のコードは、ファイル フィールドがユーザーによって入力されているかどうかを確認するためのさまざまな例を示しています。
記入されたときに、それらはすべて見つけられません。
<?php
if (isset($_POST['add']))
{
//if (!isset($_POST['pic'])) { echo"pic not filled in";}else{echo"pic filled in";}
if (!isset($_POST['pic'])) { echo"pic not filled in";}
if (isset($_POST['pic'])) { echo"pic filled in";}//end of check to see if picture has been filled in
//if (!isset($_POST['userfile[]'])) { echo"pic not filled in";}
//if (isset($_POST['userfile[]'])) { echo"pic filled in";}//end of check to see if picture has been filled in
//$pictureName = $_REQUEST['pic'];
//if ($pictureName == ''){echo"pic is blank";}
//else{echo"pic is NOT blank";}
//if ($_POST['pic'] == ""){echo"pic is blank";}
//else {echo"pic is NOT blank";}
}
else
{
/////////render form
?>
<form enctype="multipart/form-data" action="" method="post" id="save"><fieldset>
<input type="text" name="fileName" id="fileName" value=""/>
<input type="file" name="userfile[]" id="pic" />
<input name="add" id="save_button" type="submit" value="Update"/>
</fieldset></form>
<?php
}
?>