Click to See Complete Forum and Search --> : can php delete files


96turnerri
04-05-2004, 08:28 PM
hi i have looked for this on the manual, php can create files, but can it delete them? if so what is the function

Thanks
Rich

new id find it as soon as i posted here
http://www.php.net/manual/en/function.unlink.php

another question tho, hopefully i will work like last and i will find the answer :), how can i display a list of files in the same directory as the current page is in?

simpson97
04-06-2004, 01:02 AM
To delete a file you can use the:
exec() function with the unix del or erase command.
To display directory use:
opendir() & readir() functions

Bob

Sam
04-06-2004, 01:57 AM
Listing of files in current directory:
<?php
$dir = getcwd();
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
}
closedir($dh);
}
}
?>

solavar
04-06-2004, 02:39 AM
have a look at the unlink() command

Sam
04-06-2004, 02:56 PM
note his edit