I'm trying to modify a plugin so that image files from a directory can be deleted with an html link. My code spits out a table containing an image thumbnail, a link to the image, and a link to delete the file:
<?php
$dirname = "../wp-content/themes/teenclub/images/slider/";
$images = scandir($dirname);
$ignore = array(".", "..", ".DS_Store");
foreach($images as $curimg){
if(!in_array($curimg, $ignore)) {
echo "<tr ><td><img width='200' src='$dirname$curimg'/></td><td><a href='$dirname$curimg'/>$curimg</a></td><td><a href='../wp-content/plugins/wp-easy-uploader/delete.php?file=$curimg'>Delete</a></td></tr>";
};
}
?>
delete.php:
<?php
$dir = '/Users/edmcmanwich/Desktop/TEMP/dev.teenclub.com';
$file = $dir.'/'.$_GET["file"];
if(is_writable($file)) {
unlink($file);
} else {
echo 'you dont have perms dude';
}
?>
I get the message saying I don't have permission but I've chmod all the files to 777. In addition MAMP's php_error.log give me this:
[01-Feb-2012 21:10:13] PHP Warning: unlink(../wp-content/themes/teenclub/images/slider/kids.png) [<a href='function.unlink'>function.unlink</a>]: No such file or directory in /Users/edmcmanwich/Desktop/TEMP/dev.teenclub.com/wp-content/plugins/wp-easy-uploader/delete.php on line 4
The directory and file name are correct so I just don't understand what the problem is...