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.
woohoo! Thanks for sharing sis. 🙂 Happy birthday again my geeky sis. hehehe
hehehe…. lol… i remember when i don’t even know how to chmod… lol… know how you feel.
That trick looks really cool. Although I’ve never encountered that problem before.