Deleting a folder with PHP
Posted: Wed Jul 07, 2004 11:28 am
Hi all,
I'm very new to PHP... I mean VERY
In a nutshell, I need help using PHP to delete a folder, and subfolder within that folder... and every file in each.
A little background...
I've been using ASP for a couple of years now in web development and have run across a problem. For various reasons I cannot get ASP to delete a folder on the web server using File System Object.
I've read up on some PHP, but it's still very much like reading greek or latin to me still. I need to get this one page finished... and then hopefully get the heck out of ASP and start learning PHP for good.
I need to know a little bit about how to use unlink() to delete a folder.
The folder will contain .jpg images, as well as a subdirectory called "small" that also contains .jpg thumbnails.
Typically I've used this code in ASP (where "sold" is the variable containing the name of the folder):
But on this particular server we (myself and the host) can't get the permissions to work correctly (probably because it's IIS, LOL)
I want to do the same thing in PHP and see if it will work.
What I want to do is use my same ASP pages for deleting database entries that pertain to this directory, then redirect to a PHP page and pass the directory name along...
The only thing on the PHP page will be the delete code, and a redirect back. I have no knowledge of PHP functions or syntax, etc.
I'm hoping PHP will be able to do what ASP cannot in this case... or at least I want to give it a try.
This is the closest thing to helpful that I've found so far...
http://us3.php.net/unlink
and it's still confusing me...
Does all this make sense?
Is it nearly as difficult as I've made it sound?
Any help is greatly appreciated...
I'm very new to PHP... I mean VERY
In a nutshell, I need help using PHP to delete a folder, and subfolder within that folder... and every file in each.
A little background...
I've been using ASP for a couple of years now in web development and have run across a problem. For various reasons I cannot get ASP to delete a folder on the web server using File System Object.
I've read up on some PHP, but it's still very much like reading greek or latin to me still. I need to get this one page finished... and then hopefully get the heck out of ASP and start learning PHP for good.
I need to know a little bit about how to use unlink() to delete a folder.
The folder will contain .jpg images, as well as a subdirectory called "small" that also contains .jpg thumbnails.
Typically I've used this code in ASP (where "sold" is the variable containing the name of the folder):
Code: Select all
if oDelete.FolderExists (server.mappath("" & sold)) then
oDelete.DeleteFolder (server.mappath("" & sold)), true
else
response.redirect ("page.asp")
end ifI want to do the same thing in PHP and see if it will work.
What I want to do is use my same ASP pages for deleting database entries that pertain to this directory, then redirect to a PHP page and pass the directory name along...
The only thing on the PHP page will be the delete code, and a redirect back. I have no knowledge of PHP functions or syntax, etc.
I'm hoping PHP will be able to do what ASP cannot in this case... or at least I want to give it a try.
This is the closest thing to helpful that I've found so far...
http://us3.php.net/unlink
and it's still confusing me...
Does all this make sense?
Is it nearly as difficult as I've made it sound?
Any help is greatly appreciated...