上传文件后,他们被转换成一个新的数组。即时通讯制作一个显示功能,显示上传的文件+销毁他们点击
function display($type){
// echo $type;br();
// prettyR($_SESSION[$type]);
// echo"<hr>";
prettyR($_POST);
if(isset($_POST["del"])){
$p = $_POST["del"];
prettyR($_SESSION["misc"][$p]);
unlink($_SESSION["misc"][$p]["filename"]);
// $_SESSION["misc"][$p]["filename"] looks like this: upload/63eb3d2b83068_misc.jpg
unset($_SESSION["misc"][$p]);
}
echo"<form method='post'><input type='hidden' name='ka'></form>";
// this form is here so that the other forms work, because the display is in another form
if($type == "misc"){
// echo"<hr>";
// echo"hi";
foreach($_SESSION[$type] as $file){
echo"<hr>";
// echo"hi";
echo $file["name"];
$key = $file["type"];
echo"<form method='post'> <input type='hidden' value='$key' name='del'>";
echo"<input type='submit'>";
echo"</form>";
}
}
}
但却显示了以下消息
- 警告**:中未定义的数组键"63eb3d2b83c20"
我期待这个函数从文件夹中删除文件,并从misc数组中取消设置信息
1条答案
按热度按时间uemypmqf1#
如果找到答案:我一直在使用vscode.that上的live服务器意味着文件被删除后的网页重新加载,这意味着这web服务器试图unset的东西不存在.我很抱歉我的坏explaination,英语是我的母语