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:
.
..
yourtestingfilename

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); umask($u);

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


3 Comments Leave a Comment

Daynah [ Quote ]

woohoo! Thanks for sharing sis. :) Happy birthday again my geeky sis. hehehe

January 27th, 2005 at 4:05 pm
Annie [ Quote ]

hehehe…. lol… i remember when i don’t even know how to chmod… lol… know how you feel.

January 27th, 2005 at 6:31 pm
Will [ Quote ]

That trick looks really cool. Although I’ve never encountered that problem before.

January 27th, 2005 at 8:11 pm

Leave a Comment Name, email and comment are required.
Email will never be displayed.

Leave a Comment
  1. :biggrin: :blank: :blush: :bored: :confused: :cool: :down: :evil: :frown: :grin: :grr: :laidback: :left: :mad: :right: :sad: :secret: :shock: :smile: :stress: :tongue: :up: :wink: :yawn: :cute: :dead: :film: :floppy: :glasses: :grumpy: :headphones: :heart: :lightbulb: :ouch: :tv: :upsidedown: :vodka: :yell: :yuck: :yummy: