I have created a record deletion page that will properly remove the correct record in a table but the routine I added to delete the related images does not work. [Note: Due to the size of some images, I made the decision NOT to embed the pictures in the table.]
I have ensured that the image files are set to all rights '777' and that the 'pictures' folder is set to all rights '777'.
I get a good DB connection and I find the correct record in the table which has a field that contains the filename of an image. I get the related thumb by simple inserting 'thumb-' in front of the filename. To ensure that the value for $pic1 and $thumb1 is correct, I print out the filenames below:
print("pic1=$pic1<br>");
print("thumb1=$thumb1<br>");
Here is what is displayed on the web page:
pic1=http://www.mywebsite.com/pictures/129612-1.jpg
thumb1=http://www.mywebsite.com/pictures/thumb-129612-1.jpg
Those are the locations for the two images and they 'are' physically in the 'http://www.mywebsite.com/pictures/' directory.
I then execute the following UNLINK commands to delete the image files:
unlink($pic1); // line 21 in code
unlink($thumb1); // line 22 in code
However, I get the following error message:
Warning: Unlink failed (No such file or directory) in /home/webadmin/mywebsite.com/html/admin/deleteimage.php on line 21
Warning: Unlink failed (No such file or directory) in /home/webadmin/mywebsite.com/html/admin/deleteimage.php on line 22
To double-check, I tested the following code:
if (file_exists($pic1))
{
print("file exist<br>");
}
else {
print("no file exist<br>");
}
I get the "no file exist" message.
At this point, I have ensured that the folder and file rights are set to all rights, I believe the code is fairly straight forward and I have ensured that the URL of the $pic1 and $thumb1 is correct.
Anybody have any ideas on what I can try next?
Thanks.
Luke