473,625 Members | 2,600 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

delete folder

anfetienne
424 Contributor
hi ive got a folder on my server which is created by apache and the only way to delete it is with server coding.

can someone tell me a way to delete that folder including all files and folders within it?
May 8 '09 #1
4 2024
Ciary
247 Recognized Expert New Member
Expand|Select|Wrap|Line Numbers
  1. foreach(glob($mydir."/*") as $val){
  2.    if(is_dir($val)){
  3.       foreach(glob($val."/*") as $v){
  4.          if(is_dir($v)){
  5.             ...       //you'll need to do this a few times to be sure all subfolders will be deleted
  6.          }else{
  7.             unlink($v);
  8.          }
  9.       }
  10.       rmdir($mydir);
  11.    }else{
  12.       unlink($val);
  13.    }
  14. }
  15. rmdir($mydir);
May 8 '09 #2
Dormilich
8,658 Recognized Expert Moderator Expert
@anfetienne
out of interest, what causes that? and deleting via FTP didn't work (permissions?)

@anfetienne
if you have a shell prompt for your server and sufficient permissions, you may execute the appropriate commands there (e.g. rmdir -r (*nix))
May 8 '09 #3
anfetienne
424 Contributor
basically if you create folders with php code & apache you cant delete via ftp.....because the permissions set are through and for apache.....even if its 0777 you cant delete it

i had to consult my hosting company and this is what they told me
May 8 '09 #4
Dormilich
8,658 Recognized Expert Moderator Expert
ah, ok, good to know. maybe shell_exec() can help too.
May 8 '09 #5

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

Similar topics

3
2700
by: Alf Laue | last post by:
Hi, how do I delete a folder at my ftp-server, that was automatically created through a installation script? I dont have the permission to delete that folder :-( Thx for your help Alf
2
6844
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. Is there a way to make an uninstall so that it just completely wipes out my Program Files / MyApp folder no matter what?
3
2924
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 written a windows service as part of an interface between two different systems. The first system will write output into a file in a
7
12137
by: Charts | last post by:
I login as administrator of the machine. However running the following code get access denied exception for file inside the directory. The source code: DirectoryInfo target = new DirectoryInfo(TargetDirectory); target.Delete(true); I don’t have problem manually delete the whole directory. Please advice. Thanks,
9
8318
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) and two folders (Subfolder 1, Subfolder 2). .......I need to delete File1, File2, File3. Subfolder 1 contains FileA. .......Need to delete FileA. Subfolder 2 contains FileB, FileC, FileD.
3
84073
by: ad | last post by:
Hi, How can I delete all files in a folder by C# for example, I want to delete all files under c:\Test
4
6726
by: Zeb | last post by:
Hi I'm using DirectoryInfo.Delete so that when a product is removed, all it's associated images (including the folder they sit in) are deleted. This actually seems to work fine. However, the folder is not deleted, but stays and becomes totally locked down. I can no longer open it in Windows Explorer and when I try to re-launch VS 2005 debug, it complains because it can no longer monitor that folder .. because it's denied access.
24
7540
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 the folder but I get the error message when the procedure attempts to delete the folder selected in the BrowseforFolderbyPath function. How can I get it to delete the folder that the user has selected in the Browse for Folder dialog?
4
2207
by: - HAL9000 | last post by:
When un-installing an application... Is it normal practice to write a special program that erases all the files and folders for all the users of an application that reads and writes to SpecialFolder.ApplicationData (C:\Documents and Settings\Username\Application Data) ? Or, is there some way to get the ms installer to do this for you? Is there some way to use Application.UserAppDataPath to ease finding
0
2944
by: wolfsbane | last post by:
Alright, here it is I am trying to write a win32 app in VB 2005 to clean up user's profiles. everything works correctly except for the Delete("directory", True) statement. I get a System.IO.DirectoryNotFoundException: Could not find a part of the path. Then it gives me a random file name from the UserProfile\Local Settings\Temporary Internet Files\Content.IE5\SomeRandomFolder. This is absolutley driving me nuts. So I am gonn give you a basic...
0
8251
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8182
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8688
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8494
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6115
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1800
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1496
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.