我正在尝试将帖子中的数据保存到我的数组会话变量中。但是它没有添加新元素,而是覆盖了旧元素......我做错了什么?
//PHP CODE !!!
$_SESSION['file[]'] = $_FILES['file'];
$_SESSION['file_names[]'] = $_POST['file_name'];
print_r($_SESSION['file[]']); //it will only display last selected file. :(
//HTML !!!
<form method="post" action="<?=$_SERVER['PHP_SELF'];?>" enctype="multipart/form-data">
<input type="input" name="file_name" value="">
<input type="file" name="file" id="file" value="">
<input type="submit" name="SEND" value="ADD"/>
</form>
//LITLE CHECK CODE HERE !!!
//THIS CODE WILL DISPLAY " OUT OF IF STATEMENT !!!" ;/
<?php
if(isset($_SESSION['file_names[]']) && is_array($_SESSION['file_names[]'])){
foreach($_SESSION['file_names[]'] as $index => $name){
/...
}
}else{
echo " OUT OF IF STATEMENT !!!"; //executed!
}
?>
有什么想法吗?