php - 单击删除按钮时如何从文件夹中删除图像
问题描述
这是我的代码
echo"<tr>";
echo "<td>". $row["item_name"]."</td>";
echo "<td>". $row["description"]."</td>";
echo '<td><img class="avatar" src="'.$row["imglink"].'"></td>';
echo "<td>". $row["status"]."</td>";
echo '<td><a href="studentinventoryedit.php?item_id='.$row['item_id'].'"><button title="edit" type="button" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-pencil white"></span></button></a>
<a href="deleteitem.php?item_id=' . $row["item_id"].'";><button name="delete" type="button" class="btn btn-default btn-sr" data-confirm="Are you sure to delete this item?"><span class="glyphicon glyphicon-trash white"></span></button></a>';
我的PHP代码
<?php
session_start();
require 'dbconfig/config.php';
$item_id = $_GET['item_id']; // $id is now defined
$query = "DELETE from itemtbl where item_id='$item_id'";
$query_run = mysqli_query($con,$query);
$path = $_POST['imglink'];
header("Location: studentinventory.php?"); //redirect to relevant page
?>
如果我单击删除,它将传递 id,并删除项目文件,但图像没有被删除。我试图用谷歌搜索如何从文件夹中删除图像,但没有这样做。
解决方案
推荐阅读
- python - SMOTENC:无法将字符串转换为浮点数
- ios - iOS HERE SDK NMAKit 私有 API 使用
- maven - 无论如何要在 github 操作工作流中签署 maven 包吗?
- excel - 使用 VBA 和 IBM Lotus Notes 发送电子邮件
- regex - 正则表达式 (0*1*)* 和 (0 + 1)* 是否相同?
- splunk - 从请求正文 splunk 中提取所有出现的相同字段
- apache-spark - 在 RDD 的过滤器转换中没有得到预期的结果
- vba - MS 访问错误 91 对象变量或未在第 0 行设置块变量
- flutter - Flutter 和 Firestore:调试使用
- java - 在 Android 5.1.1 上膨胀类 androidx.appcompat.widget.SearchView 时出错