Multiple file Delete
| From: | Lenny Davila | Date: | Wed, 16 Jun 2004 20:07:32 +0000 |
| Subject: | Multiple file Delete | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-23995@lists.php.net to get a copy of this message | ||
I need to be able to delete multiple files from my web server by choosing
one file. I have a directory of thumbs named "images" and a directory
called "big" with text files and Full images. If I was to delete the file
"image1.jpg" I want it to delete "image1.jpg" in the images, the big folder
and "image1.jpg.txt" in the big folder. I have now in my code.
($file = file to be deleted)
if($action=="dele" && $confirm==1) {
$match=array();
// Create an array of files
$match[]=$file;
// Put filename in the array
$dirHandle = dir('../');
// get recursive directory listing from the directory above
while($fileHandle = $dirHandle->read()) {
// while reading the directory
$delFile = strrchr($fileHandle, "/");
// get the filename after the last "/"
if (in_array(substr($delFile,0,5), $match)) {
// this line compares the 5 first chars in the filename
// with the names in the $match array
// Next line is line 36
unlink($delFile); $action="";}
// delete all files that match the filename
if (unlink($delFile)) {
echo "Removed the file $fileHandle<br> \n";
}
}
}
The first error I get:
Warning: unlink(): No such file or directory in
/home/www/mathiu1i/php/gallerie/edit2.php on line 36
TIA
------------------------------------
Eleno Davila
lenny@plasticsurgery.com
(877)933-6750 Ext 163 (direct line)
http://plasticsurgery.com