|
|
|
|
![]() ![]() |
Sep 15 2005, 05:09 PM
Post
#1
|
|
|
Incest is a game the whole family can play. ![]() Group: [MODERATOR] Posts: 1,205 Joined: 11-February 05 From: Heaven Member No.: 3,709 |
How To Delete Files and Directories
follow up from creating them Hello all and welcome to my second tutorial involving file management. In my previous tutorial, I explained how to create, write and read files. In this tutorial I'll explain how to remove the files and directories you took so long to create. I did not explain last time how to create directories as I did not know, now I do, you can use the mkdir() function. Now with this tutorial.... Removing Files Removing files can easily be done with the unlink() function: CODE <? unlink("stuffStorge.txt"); ?> The file which you wish to remove must have 0777 chmod permissions aswell as the directory that the file is stored in. Removing Directories I have never tried doing this myself but it can be done with the rmdir() function, but I presume like unlink() both the directory you are trying delete and the one that the directory is stored in must have 0777 permissions: CODE <? rmdir("/home/bla/public_html/"); ?> All in all a very simple tutorial explaining this, any questions? |
|
|
|
Sep 15 2005, 05:48 PM
Post
#2
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 12 Joined: 12-September 05 Member No.: 11,794 |
!! The file which you wish to remove must have 0777 chmod permissions !!
the question is how change the permissions with PHP? is possible? |
|
|
|
Sep 15 2005, 06:42 PM
Post
#3
|
|
|
apt-get moo ![]() Group: [MODERATOR] Posts: 2,055 Joined: 28-May 05 From: Hertfordshire, England Member No.: 7,593 ![]() |
Yes, use this code to change CHMOD values. You must use octal numbers (e.g. always have 4 digits starting with 0).
CODE chmod("/adirectory/", 0777); //Will CHMOD a directory chmod("/adirectory/afile.txt",0777); //Will CHMOD a file Hope this helps. |
|
|
|
Sep 17 2005, 04:18 AM
Post
#4
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 623 Joined: 26-August 05 Member No.: 11,160 |
thanks for this i havent really had any problems deleting files yet but i havent really done anything big like that but i think i am going to delete some stuff so i hope this tutorial will come in use to me when i am doing the file deleting
|
|
|
|
Oct 5 2005, 12:10 AM
Post
#5
|
|
|
Newbie [Level 3] ![]() ![]() ![]() Group: Members Posts: 46 Joined: 11-September 05 Member No.: 11,743 |
The biggest problem with chmod() is that most of the servers will restrict PHP from using it.
I don't know about Trap17 though |
|
|
|
Jan 11 2008, 05:09 AM
Post
#6
|
|
|
Trap Double Mocha Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 2,360 Joined: 21-September 07 Member No.: 50,369 |
2 Questions CHMOD || MySql
Delete Files And Directories Using Php 1) what is CHMOD ? What does it do ? 2) I'm currently making a website that people can make they're selves members on but when I try and interact with mySql db it says "Undefined function mySwl_Connect()" Whats that about ? ive tryied everything; [Example] $String = "MydataBase.Sql"; $con = mysql_connect($String); [/Example] But I always get the same error. I've checked my php.Ini file but everything *seems* oright. Any ideas ? Any help appreciated, Thanks, Mark. -Huzi |
|
|
|
Jan 17 2008, 12:05 AM
Post
#7
|
|
|
Trap Double Mocha Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 2,360 Joined: 21-September 07 Member No.: 50,369 |
Deleting a directory and its content
Delete Files And Directories Using Php I'm trying to use rmdir() to delete a directory, but I'm getting "Directory not empty" error. How can I remove the directory and its content? -Sharif |
|
|
|
Mar 26 2008, 05:25 PM
Post
#8
|
|
|
Trap Double Mocha Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 2,360 Joined: 21-September 07 Member No.: 50,369 |
How do I delete a file wich is located in a different directory
Delete Files And Directories Using Php I have all my php files in a directory called templates, and I need to remove (delete) files (jpg) in a directory called photos. My Directory list looks like this: Root/ /photos/ image1.Jpg image2.Jpg /templates/ removingfiles.Php I'm trying with unlink() $myFile = "../photos/".$filename; Unlink($myFile); But nothing happens... Any idea? Thanks! -question by Mr Serra |
|
|
|
![]() ![]() |
Similar Topics