プラグインを変更して、ディレクトリの画像ファイルをhtmlリンクで削除できるようにしようとしています。私のコードは、画像のサムネイル、画像へのリンク、およびファイルを削除するためのリンクを含むテーブルを吐き出します。
<?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';
}
?>
権限がないというメッセージが表示されますが、すべてのファイルを777にchmodしました。さらに、MAMPのphp_error.logから次のように表示されます。
[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
ディレクトリとファイル名が正しいので、何が問題なのかわかりません...