0

I'm still trying to learn myself some more php and I'm currently working on a script to upload and remove images to and from my server. Now uploading is working all fine, also deleting from database isn't a problem. The only problem that occurs is removing the image itself from the uploads folder on my server.

Below is my code. The echo statement spits out the following url: 479_1293904366__sdc14139.jpg I honestly can't seem to find my mistake, and your help would be greatly appreciated.

Thanks in advance!

$unlinkafbeelding = "SELECT * FROM Afbeeldingen WHERE id = $ID";
$select = mysql_query($unlinkafbeelding) or die('Error, je bent een mongool');
$image = mysql_fetch_array($select);
echo($image['naam']);
unlink($image['naam']);
Boudewijn Smit
  • 177
  • 2
  • 4
  • 13
  • 1
    If it spits out `479_1293904366__sdc14139.jpg`, then it will only delete the file if it is in the SAME folder as the PHP file, else you need to specify the directory: `unlink('path/to/images/' . $image['naam']);` – h2ooooooo Sep 12 '12 at 18:20
  • Omg, that's probably my worst mistake ever. Thanks a lot though I've been staring myself to death! – Boudewijn Smit Sep 12 '12 at 18:24

1 Answers1

2

Do you get any errormessages? Maybe it's because the images isn't stored in the same folder as the directory where the script is executed. Make sure that the path to the image is correct.

Otherwise post your errormessage. If you don't get any message insert the folowing line into your php script and run it again. Than every Message should be displayed.

error_reporting (E_ALL);
chresse
  • 5,486
  • 3
  • 30
  • 47