elite_prodigy Posted April 3, 2008 Share Posted April 3, 2008 I think I read about this somewhere, but I can't think how to accomplish it. Can someone tell me the functions, and maybe give me a few examples? I need to be able to create folders(directories) and files dynamically when a user registers. Quote Link to comment Share on other sites More sharing options...
almightyegg Posted April 3, 2008 Share Posted April 3, 2008 fopen() shoudl do it I believe Quote Link to comment Share on other sites More sharing options...
discomatt Posted April 3, 2008 Share Posted April 3, 2008 and mkdir() Quote Link to comment Share on other sites More sharing options...
almightyegg Posted April 3, 2008 Share Posted April 3, 2008 Oh yes forgot that one Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted April 3, 2008 Author Share Posted April 3, 2008 Can you explain how to use them, like an example. Say I want to build a file called "posting.php" in "http://www.somesite.com/stuff" how would I do it? Quote Link to comment Share on other sites More sharing options...
marcus Posted April 3, 2008 Share Posted April 3, 2008 <?php $folder = "/stuff/"; $file = "posting.php"; if(file_exists($folder . $file)){ if(!$_GET['rewrite']){ echo "This file exists, <a href=\"?rewrite=yes\">click here</a> to over write with a new file!\n"; }else { unlink($folder . $file); $f = fopen($folder . $file, "w+"); fclose($f); echo $file . " has been created in the folder <b>".$folder."</b>\n"; } }else { $f = fopen($folder . $file, "w+"); fclose($f); echo $file . " has been created in the folder <b>".$folder."</b>\n"; } ?> example. Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted April 3, 2008 Author Share Posted April 3, 2008 Warning: mkdir() [function.mkdir]: Permission denied in /home/expose/public_html/exposeyourschool.co.cc/register.php on line 3 Is there anyway around this error? Quote Link to comment Share on other sites More sharing options...
almightyegg Posted April 3, 2008 Share Posted April 3, 2008 The parent directory has chmod set to private probably. Quote Link to comment Share on other sites More sharing options...
trq Posted April 4, 2008 Share Posted April 4, 2008 Why do you need to create directories and files when a user registers? Much easier to use one file for all users, store there relevent data in a database and use mod_rewrite to give the impression each user has there own directory. this is pretty much the basics of dynamic website creation. Do you think this forum creates a new page everytime someone adds a new thread? Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted April 4, 2008 Author Share Posted April 4, 2008 I'm building a new website for each user. So their site name will be www.somesite.com/their-site-name Thus, I need to create directories and files dynamically upon registration. Unless you have a better method? Please, I'm open to ALL suggestions! Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted April 4, 2008 Author Share Posted April 4, 2008 *bump* Anyone? Quote Link to comment Share on other sites More sharing options...
trq Posted April 6, 2008 Share Posted April 6, 2008 Thus, I need to create directories and files dynamically upon registration. Unless you have a better method? I just gave you my better method in my last reply. This really is the basics of dynamic website creation. 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.