I am getting this Error message when trying to delete image files via the Unlink function:
Warning: unlink() [function.unlink]: http does not allow unlinking in /var/www/html/anoox.com/inc/db_news.php on line 269
But I am able to delete image files via Unlink function Ok from other Php programs.
Note, only different between the db_news.php where the Unlink function produces Error and other Php files via where the Unlink function is working Ok is that db_news.php is an included file, which means it is being
loaded via include into another Php file which is then calling a function in db_news.php which function
has the job of deleting desiganted files via Unlink.
I totally suspect on the path of deleting file that you have given to the unlink function. It does not support URL paths before PHP 5 but supports URLs after 5.0 with some URL warppers. Can we see the code and also let us know the path & name of the file that you have passed to unlink function?
Here is the function in the included file which has the job of deleting given filenames:
function delete_fotos ($article_id, $user_id)
{
//1st physically delete the images b4 deleting them from the DB
$sql_get_images = “SELECT number, type FROM user_images WHERE article_id = $article_id”;
$query_get_images = mysql_query($sql_get_images) or die(mysql_error());
if (mysql_num_rows($query_get_images) > 0) {
while ($result_get_images = mysql_fetch_array($query_get_images)) {
$number = $result_get_images['number'];
$type = $result_get_images['type'];
$file_name = $user_id . '_' . $article_id . '_foto' . $number . '.' . $type;
$target_path = 'http://www.anoox.com/news/user_images/' . $file_name;
unlink($target_path);
}//CLOSES While Loop
}//CLOSES if (mysql_num_rows($query_get_images) > 0)
$sql_remove_fotos = "DELETE FROM user_images WHERE article_id = $article_id";
mysql_query($sql_remove_fotos) or die(mysql_error());
}
FYI, here is the actual URL to a typical image file:
Did you read my post above clearly that the function unlink does not support http URLs. You have used ‘http://www.anoox.com/news/user_images/’ . $file_name;. You need to use /path/to/the/image/image.jpg instead.
Actually I already solved the problem based on your past message that Php does not support absolute URLs by switching to relative URL.
ThanX.
Now I have to update all the codes where the delete_foto function is being called to give it the path modifier to the relative path. Joy