我正在嘗試編寫腳本來上傳腳本以從我的服務器中刪除圖像。我不斷收到錯誤消息。任何人都可以找到這個代碼有問題嗎?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