lvertel Posted March 24, 2009 Share Posted March 24, 2009 hello people here is my simple problem : // CREATING ARTIST FOLDER mkdir("users/".$username.""); chmod("users/".$username."",0777); mkdir("users/".$username."/".$name_artist."/images" ); chmod("users/".$username."/".$name_artist."/images",0777); mkdir("users/".$username."/".$name_artist."/images/thumbs"); chmod("users/".$username."/".$name_artist."/images/thumbs",0777); // END CREATING ARTIST FOLDER i am having 3 MKDIR's... first one is working, but the other 2 doesnt... .what is the prob :S ???? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 24, 2009 Share Posted March 24, 2009 you should just be able to do this: <?php mkdir("users/".$username."/".$name_artist."/images/thumbs",0777,true); ?> Quote Link to comment Share on other sites More sharing options...
lvertel Posted March 24, 2009 Author Share Posted March 24, 2009 hey rhodesa. this is not working because i am working on a windows server, and i need to do mkdir first and then chmod.... but anyway, my problem is creating the subfolders... Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 24, 2009 Share Posted March 24, 2009 k, then: <?php mkdir("users/".$username."/".$name_artist."/images/thumbs",0777,true); chmod("users/".$username."",0777); chmod("users/".$username."/".$name_artist."/images",0777); chmod("users/".$username."/".$name_artist."/images/thumbs",0777); ?> the mkdir() with that true on the end should recursively create all the folders Quote Link to comment Share on other sites More sharing options...
lvertel Posted March 24, 2009 Author Share Posted March 24, 2009 damn, still doesnt work... basically this is what i have : -ROOT -USERS -SCRIPTS -IMAGES my php files are in root folder,and i want to create those folders in USERS folder. i tried your code but i cant ..it says : "[17:23:05] 550 /httpdocs/users/-4/bib: No such file or directory" (in ftp), and permissions are at 700...so i cant even delete... hmmm, i really wonder how could i create those folders in USER ?? Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted March 24, 2009 Share Posted March 24, 2009 Here's a function to handle this function mkdir_recursive($pathname, $mode) { is_dir(dirname($pathname)) || mkdir_recursive(dirname($pathname), $mode); return is_dir($pathname) || @mkdir($pathname, $mode); } then you would use it like this $old=umask(0); $path="users/".$username."/".$name_artist."/images/tumbs",0777); mkdir_recursive($path, 0777); umask($old); hello people here is my simple problem : // CREATING ARTIST FOLDER mkdir("users/".$username.""); chmod("users/".$username."",0777); mkdir("users/".$username."/".$name_artist."/images" ); chmod("users/".$username."/".$name_artist."/images",0777); mkdir("users/".$username."/".$name_artist."/images/thumbs"); chmod("users/".$username."/".$name_artist."/images/thumbs",0777); // END CREATING ARTIST FOLDER i am having 3 MKDIR's... first one is working, but the other 2 doesnt... .what is the prob :S ???? Quote Link to comment Share on other sites More sharing options...
lvertel Posted March 24, 2009 Author Share Posted March 24, 2009 ok ill try this, but did i tell you that the USERS/$USERNAME ----> that is already created now i need to put $artist_name/$images in the $username folder.... u understand ? Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted March 24, 2009 Share Posted March 24, 2009 That's fine is_dir(dirname($pathname)) || mkdir_recursive(dirname($pathname), $mode); if it's a directory or it can make directory it moves on to the next Quote Link to comment Share on other sites More sharing options...
lvertel Posted March 24, 2009 Author Share Posted March 24, 2009 huh, your function returns a white screen.... Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 24, 2009 Share Posted March 24, 2009 let's back up...if you echo $username, what is it? cus your error leads me to believe it's -4 ??? Quote Link to comment Share on other sites More sharing options...
lvertel Posted March 24, 2009 Author Share Posted March 24, 2009 if i ECHO it with your function, it brings me nothing, blank screen.. but if i just delete your function and echo $username, it gives me : lvertel ....which is my account with whom im testing everything... Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 24, 2009 Share Posted March 24, 2009 ok...let's try this: <?php $folder = "users/{$username}/{$name_artist}/images/thumbs"; echo "Trying to create folders: $path<br />"; $paths = explode('/',$folder); $path = ""; for($n=0;$n < count($paths);$n++){ $path .= $paths[$n].'/'; mkdir($path,0777) or die("Could not make: $path"); chmod($path,0777) or die("Could not chmod: $path"); print "Done with: $path<br />"; } print "Done!"; ?> Quote Link to comment Share on other sites More sharing options...
lvertel Posted March 24, 2009 Author Share Posted March 24, 2009 this is what i get : Trying to create folders: Could not make: users/ Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 24, 2009 Share Posted March 24, 2009 sorry...should test to see if the folder exists: <?php $folder = "users/{$username}/{$name_artist}/images/thumbs"; echo "Trying to create folders: $path<br />"; $paths = explode('/',$folder); $path = ""; for($n=0;$n < count($paths);$n++){ $path .= $paths[$n].'/'; if(is_dir($path)) print "Folder already exists: $path<br />"; else mkdir($path,0777) or die("Could not make: $path"); chmod($path,0777) or die("Could not chmod: $path"); print "Done with: $path<br />"; } print "Done!"; ?> Quote Link to comment Share on other sites More sharing options...
lvertel Posted March 24, 2009 Author Share Posted March 24, 2009 lol, nothing comes out... anyway, i dont understand why u try to echo : "trying to create folders : $path.... when path wasnt declared yet ???? lol Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted March 24, 2009 Share Posted March 24, 2009 echo out your variables and make sure they're right. Because in windows you can't create a "-4" folder. That's what causing the problem. The function I put up there would work fine if the folder name was valid. echo "Username: ".$username."<br>"; echo "Name_Artist: ".$name_artist."<br>"; Quote Link to comment Share on other sites More sharing options...
lvertel Posted March 24, 2009 Author Share Posted March 24, 2009 well it echo's the username(lvertel) and the artist name i give it to him... Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted March 24, 2009 Share Posted March 24, 2009 how about posting all the code, because at some point the Name equals "-4" Quote Link to comment Share on other sites More sharing options...
lvertel Posted March 24, 2009 Author Share Posted March 24, 2009 hey, my code in the php is VERY long, so i attached the .php file here.. you can find it on the line 98 !!! [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 24, 2009 Share Posted March 24, 2009 lol, nothing comes out... anyway, i dont understand why u try to echo : "trying to create folders : $path.... when path wasnt declared yet ???? lol you are correct...i meant $folder for that print statement: <?php $folder = "users/{$username}/{$name_artist}/images/thumbs"; echo "Trying to create folders: $folder<br />"; $paths = explode('/',$folder); $path = ""; for($n=0;$n < count($paths);$n++){ $path .= $paths[$n].'/'; if(is_dir($path)) print "Folder already exists: $path<br />"; else mkdir($path,0777) or die("Could not make: $path"); chmod($path,0777) or die("Could not chmod: $path"); print "Done with: $path<br />"; } print "Done!"; ?> Quote Link to comment Share on other sites More sharing options...
lvertel Posted March 24, 2009 Author Share Posted March 24, 2009 grrrr i tried it and this is the result : Trying to create folders: users/lvertel/ppp/images/thumbs Folder already exists: users/ Could not chmod: users/ it didnt create the folder, i guess it sees that the folder USERS is already here so it dont create subfolders :s Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 24, 2009 Share Posted March 24, 2009 what are the permissions on the users folder? Quote Link to comment Share on other sites More sharing options...
lvertel Posted March 24, 2009 Author Share Posted March 24, 2009 all 777... i think its the problem that he wants to create a folder users/etc... n then he see users is already made, so he stops :s Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 24, 2009 Share Posted March 24, 2009 well...not sure what else to say. i'm more of a LAMP then a WAMP guy Quote Link to comment Share on other sites More sharing options...
DavidT Posted March 26, 2009 Share Posted March 26, 2009 I guess that's the point... By using that explode system, the first time you're attempting to create "users/". That exists already, so you get error. You can try by setting $n=1 in the first for... but then it tries to create "Ivertel/" and this does exists also if I get it right, isn't it? Actually what's the point in all that explode stuff? all 777... i think its the problem that he wants to create a folder users/etc... n then he see users is already made, so he stops :s Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.