473,396 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Delete a folder...It worked and now it doesn't

142 100+
Hi, Please help here

I made this delete script to delete a folder on the hosting server and the files within.

It worked a month ago but now it does not work...

[PHP]
<?php

$dfolder = $_POST['dfolder'];

$myFile = "$dfolder";
rmdir($myFile);

?>
[/PHP]

It worked on my local server as well but also it aint working on it.

I tried unlink, unset, FTP_delete and the one that is suppose to work rmdir. I even set the permission but the permission are right.

Can some please tell me why it worked and now does not want to work!
Jul 17 '07 #1
6 3717
dafodil
392 256MB
Hi, Please help here

I made this delete script to delete a folder on the hosting server and the files within.

It worked a month ago but now it does not work...

[PHP]
<?php

$dfolder = $_POST['dfolder'];

$myFile = "$dfolder";
rmdir($myFile);

?>
[/PHP]



It worked on my local server as well but also it aint working on it.

I tried unlink, unset, FTP_delete and the one that is suppose to work rmdir. I even set the permission but the permission are right.

Can some please tell me why it worked and now does not want to work!
Check if you have the existing folder before you delete....
Is there any errors? If yes please show the error....
Jul 17 '07 #2
webandwe
142 100+
Hi, no it is just a folder with images it it.

The error I get is.

The directory is not empty...It always deleted the files in the folder and then the folder but now I just get that error message.

Regards
Jul 17 '07 #3
epots9
1,351 Expert 1GB
give this a try http://us3.php.net/manual/en/function.exec.php

[PHP]
echo exec('rm - r '.$myFile);
[/PHP]
Jul 17 '07 #4
nomad
664 Expert 512MB
Hi, Please help here

I made this delete script to delete a folder on the hosting server and the files within.

It worked a month ago but now it does not work...

[PHP]
<?php

$dfolder = $_POST['dfolder'];

$myFile = "$dfolder";
rmdir($myFile);

?>
[/PHP]

It worked on my local server as well but also it aint working on it.

I tried unlink, unset, FTP_delete and the one that is suppose to work rmdir. I even set the permission but the permission are right.

Can some please tell me why it worked and now does not want to work!
webandwe
Two thing you can do.
Make sure you have the right dir. and that the folder is spelled the same as your code.
or
make a new folder and then change your code dfolder to the new folder name.

nomad
Jul 17 '07 #5
mwasif
802 Expert 512MB
PHP manual says The directory must be empty. Checkout the manual rmdir().
Jul 17 '07 #6
Motoma
3,237 Expert 2GB
This code may help you out:

Expand|Select|Wrap|Line Numbers
  1. <?
  2. /********************************************************************
  3.                                 rm.php
  4. ********************************************************************/
  5. /*
  6.     Deletes a file or directory
  7.     Usage:  rm("filename");
  8.             rm("directory");
  9.             rm("directory/*");
  10.             rm("*.txt");
  11. */
  12. function rm($fileglob)
  13. {
  14.    if (is_string($fileglob))
  15.    {
  16.        if (is_file($fileglob)) return unlink($fileglob);
  17.        else if (is_dir($fileglob))
  18.        {
  19.            $ok = rm("$fileglob/*");
  20.            if (! $ok) return false;
  21.            return rmdir($fileglob);
  22.        } else {
  23.            $matching = glob($fileglob);
  24.            if ($matching === false)
  25.            {
  26.                trigger_error(sprintf('No files match supplied glob %s', $fileglob), E_USER_WARNING);
  27.                return false;
  28.            }
  29.            $rcs = array_map('rm', $matching);
  30.            if (in_array(false, $rcs)) return false;
  31.        }
  32.     }
  33.     else if (is_array($fileglob))
  34.     {
  35.         $rcs = array_map('rm', $fileglob);
  36.         if (in_array(false, $rcs)) return false;
  37.     } else {
  38.         trigger_error('Param #1 must be filename or glob pattern, or array of filenames or glob patterns', E_USER_ERROR);
  39.         return false;
  40.     }
  41.     return true;
  42. }
  43.  
Jul 17 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: jenny | last post by:
Hi, I am trying to find a VB way that would create a folder on all existing drives - the folder name would be the same on each drive. ie c:\backup, d:\backup, etc. But the folders would only be...
4
by: Mark Reed | last post by:
Hi all, I have the following code which imports the contents of all files within a set folder which works excellently. Once it has imported from each file, it deletes the file. Is there a way that...
2
by: Keith Smith | last post by:
I have noticed that when I uninstall my app it doesn't delete the Program Files / MyApp folder if there are "new" files in it that weren't there before. It deletes all files except the "new" ones....
3
by: News | last post by:
Is it possible to delete a file by copying it to the "bit bucket" or "null device"? Back in my youth when I live in VMS-land you could delete a file by copying it to NL: ========== I have...
3
by: krock_112 | last post by:
I'm trying to set up a group of shared folders. Folder 1 Folder 2 Common Share I want all users that have access to folder 2 to be able to create new folders, add documents to the sub folders,...
9
by: Paul | last post by:
I'm trying to make get my app to delete all the files in a specified folder and all the files within the folders of the specified folder. e.g. Folder 1 contains three files (File1, File2, File3)...
29
by: Jon Slaughter | last post by:
Is it safe to remove elements from an array that foreach is working on? (normally this is not the case but not sure in php) If so is there an efficient way to handle it? (I could add the indexes to...
24
by: biganthony via AccessMonster.com | last post by:
Hi, I have the following code to select a folder and then delete it. I keep getting a Path/File error on the line that deletes the actual folder. The line before that line deletes the files in...
6
by: fyitang | last post by:
hi guys, here is the sample: string strFileFullName = ""; try { FileInfo currentFile = GetOneFile("some directory"); strFileFullName = currentFile.FullName; // do someting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.