how to delete files from root dir.
Moderator: General Moderators
- itsmani1
- Forum Regular
- Posts: 791
- Joined: Mon Sep 29, 2003 2:26 am
- Location: Islamabad Pakistan
- Contact:
how to delete files from root dir.
i want to delete all .html and .htm files from root directory
how can i do so?
one morething is
i want to convert my php extension to html for example
http://maair.net/content.php i want to convert it to .html but it should work as it is working Dynamically
thanks
how can i do so?
one morething is
i want to convert my php extension to html for example
http://maair.net/content.php i want to convert it to .html but it should work as it is working Dynamically
thanks
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
glob() or opendir()-readdir() to build a file list, unlink() to delete. Be aware: it will not be able to delete files it doesn't have permission to.
You have to add .html as a php parsed type then rename the file. Be aware that all .html files, whether they have php in them or not, will be processed by php.
You have to add .html as a php parsed type then rename the file. Be aware that all .html files, whether they have php in them or not, will be processed by php.
-
SKDevelopment
- Forum Newbie
- Posts: 13
- Joined: Thu Jan 26, 2006 10:42 am
Re: how to delete files from root dir.
It would be advisable also to replace the unlink() command with echo and see which files your script is going to delete before you do any actual deleting.
--
Best Regards,
Sergey Korolev
www.skdevelopment.com
--
Best Regards,
Sergey Korolev
www.skdevelopment.com
Code: Select all
echo ` rm -rf /path/*.html`;using apache?
you could use a mod rewrite (assuming all .html files are .php) and give the illusion that it's an .html file (don't know if that's what you're going for).
.htaccess file
you could use a mod rewrite (assuming all .html files are .php) and give the illusion that it's an .html file (don't know if that's what you're going for).
.htaccess file
Code: Select all
RewriteEngine On
RewriteRule ^(.+)\.html$ $1\.phpSet Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- itsmani1
- Forum Regular
- Posts: 791
- Joined: Mon Sep 29, 2003 2:26 am
- Location: Islamabad Pakistan
- Contact:
Code: Select all
$dir = "../";
if (is_dir($dir)) {
if ($dh = opendir($dir))
{
foreach (glob("*.html") as $filename)
{
unlink($filename);
}
}
}abc/xyz
i am in xyz rign now and want to delete all .html files of abc
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
This won't work if the files were uploaded by FTP. You'll need to CHMOD them first.itsmani1 wrote:directory strucure is like this:Code: Select all
$dir = "../"; if (is_dir($dir)) { if ($dh = opendir($dir)) { foreach (glob("*.html") as $filename) { unlink($filename); } } }
abc/xyz
i am in xyz rign now and want to delete all .html files of abc
Note your path to unlink is wrong. You need to prepend the $dir too.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia