Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 2nd, 2007, 05:15 AM
Registered User
 
Join Date: Nov 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to delete folder with php

please tell me how to coding to delete folder with PHP

thanks

 
Old November 8th, 2007, 09:30 AM
Registered User
 
Join Date: Nov 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to asanga
Default

<?php
rmdir("StringFolderName");
?>

Asanga Amarawansa
asanga@needmatch.biz
http://www.needmatch.biz/
 
Old November 8th, 2007, 06:26 PM
Authorized User
 
Join Date: Sep 2007
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default

rmdir will only remove the directory if no files exist in it. Let me know if you want the code to remove a directory (that contains files) and or subfolders within it.

http://mynameissteve.com
 
Old November 8th, 2007, 08:39 PM
Registered User
 
Join Date: Nov 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to asanga
Default

then you have to use a function to do that
there is a function in this page
http://www.php.net/rmdir


Asanga Amarawansa
asanga@needmatch.biz
http://www.needmatch.biz
 
Old March 26th, 2008, 02:59 AM
Registered User
 
Join Date: Nov 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 function removedir($dirname)
    {
        if (is_dir($dirname))
        $dir_handle = opendir($dirname);
        if (!$dir_handle)
        return false;
        while($file = readdir($dir_handle)) {
            if ($file != "." && $file != "..") {
                if (!is_dir($dirname."/".$file))
                unlink($dirname."/".$file);
                else
                {
                    $a=$dirname.'/'.$file;
                    removedir($a);
                }
            }
        }
        closedir($dir_handle);
        rmdir($dirname);
        return true;
    }






Similar Threads
Thread Thread Starter Forum Replies Last Post
php/mysql delete button and delete query dungey PHP Databases 17 April 11th, 2009 12:24 PM
PHP no longer compiling (inetpub folder problem?) rayburn Beginning PHP 3 January 10th, 2008 02:04 PM
Delete file from folder using FileOutputStream kotaiah Java Basics 1 March 8th, 2007 04:47 AM
Can Global.asa be used to delete a folder. solos Classic ASP Basics 9 February 13th, 2007 06:05 PM
Commit.PHP and Delete.PHP in WROX's book GiFos Beginning PHP 0 January 30th, 2007 10:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.