我正在尝试编写脚本来上传脚本以从我的服务器中删除图像。我不断收到错误消息。任何人都可以找到这个代码有问题吗?PHP解除链接保持失败
// Delete image
if(isset($_GET['deleteImg']) && !empty($_GET['deleteImg']) && $_GET['deleteImg'] == true)
{
// Get imagepath from database
$result = mysql_query("SELECT image FROM frankkluytmans WHERE id=$id");
$imageDeletePath = mysql_fetch_assoc($result);
// Delete image from server
if(unlink($imageDeletePath['image']))
{
// Continue if image has been reset in database
if(mysql_query("UPDATE frankkluytmans SET `image`='' WHERE id=$id")){
// once deleted, redirect back to the view page
header("Location: index.php");
}
}
else
{
?>
<script type="text/javascript">
window.alert('This image could not be deleted.';
</script>
<?
}
}
是在db字段中的绝对路径吗?你可能会从不同的位置调用'unlink',所以它不起作用,因为它找不到文件 – Fabio
db字段中的路径是这样的:/gfx/image.png –
,你现在在哪个目录中? – Fabio