Jump to content

Creating Files Dynamically With PHP?


elite_prodigy

Recommended Posts

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

<?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.

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?

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.