geeky · personal

OMG geeky bday gift

ok i got my best geeky birthday gift today. LOL, you will have to be a geek to understand my excitement right now. hehehehe i’m soooooooooo happy.

you know how when you use opendir and readdir, you have to chmod your folder to 755 or 777 first? and how if you use mkdir, you won’t be able to delete the directory you created in ftp? it’s such a hassle. i just learned today that you don’t have to. OMG!! i wish i knew this sooner. the trick is to use umask.

if you want to try, just create a directory called test on your domain root, and put a testing file in it. i just put a random jpg. then paste the following code:

	$old = umask(0); 
	if($dh = opendir($_SERVER[DOCUMENT_ROOT]."/test")) { 
		while (($file = readdir($dh)) !== false) { 
			echo $file."<br />\n"; 
	} umask($old); 

to a text file and name it “test.php”. upload it to your domain and run it. you should see something like:


it worked for me. so no chmod. OMG i’m so happy, now i don’t have to chmod all the folders i upload in my gallery folder. muahahahaha!!!!

on the other hand, if you were to create a dir with mkdir. use the code below:

$u = umask(0); 
mkdir($path_to_ur_dir, 0777); 

that way you can easily delete the folder you created with ftp.

3 thoughts on “OMG geeky bday gift

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s