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. Link to comment https://forums.phpfreaks.com/topic/99433-creating-files-dynamically-with-php/ Share on other sites More sharing options...
almightyegg Posted April 3, 2008 Share Posted April 3, 2008 fopen() shoudl do it I believe Link to comment https://forums.phpfreaks.com/topic/99433-creating-files-dynamically-with-php/#findComment-508772 Share on other sites More sharing options...
discomatt Posted April 3, 2008 Share Posted April 3, 2008 and mkdir() Link to comment https://forums.phpfreaks.com/topic/99433-creating-files-dynamically-with-php/#findComment-508775 Share on other sites More sharing options...
almightyegg Posted April 3, 2008 Share Posted April 3, 2008 Oh yes forgot that one Link to comment https://forums.phpfreaks.com/topic/99433-creating-files-dynamically-with-php/#findComment-508778 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? Link to comment https://forums.phpfreaks.com/topic/99433-creating-files-dynamically-with-php/#findComment-508782 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. Link to comment https://forums.phpfreaks.com/topic/99433-creating-files-dynamically-with-php/#findComment-508790 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? Link to comment https://forums.phpfreaks.com/topic/99433-creating-files-dynamically-with-php/#findComment-508829 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. Link to comment https://forums.phpfreaks.com/topic/99433-creating-files-dynamically-with-php/#findComment-508840 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? Link to comment https://forums.phpfreaks.com/topic/99433-creating-files-dynamically-with-php/#findComment-508967 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! Link to comment https://forums.phpfreaks.com/topic/99433-creating-files-dynamically-with-php/#findComment-509286 Share on other sites More sharing options...
elite_prodigy Posted April 4, 2008 Author Share Posted April 4, 2008 *bump* Anyone? Link to comment https://forums.phpfreaks.com/topic/99433-creating-files-dynamically-with-php/#findComment-509551 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. Link to comment https://forums.phpfreaks.com/topic/99433-creating-files-dynamically-with-php/#findComment-510481 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.