PDA

View Full Version : Auto File Creation?


defi
03-23-2005, 02:40 AM
Okay, my ultimate goal here is when a user submits a form, it's going to put a new index.php file into the specified directory, which would redirect it to a page I defined. Is there any way to do this?

WhSox21
03-23-2005, 03:24 AM
Yes, it's possible but you need way more information than just what you provided. With what you're trying to do you might be able to use mod_rewrite and just one file. It all depends on what you're trying to do though.

hate
03-23-2005, 03:45 AM
I seen your post about mkdir so this may be what your after

$filecontent="Code For File To Insert";
mkdir('/home/path/public_html/'.$username, 0777);
if ($fp = fopen("/home/path/public_html/".$username."/index.php", "w")) {
fwrite($fp, $filecontent);
chmod("/home/path/public_html/".$username."/index.php", 0755);
fclose($fp);
}

defi
03-23-2005, 04:03 AM
I seen your post about mkdir so this may be what your after

$filecontent="Code For File To Insert";
mkdir('/home/path/public_html/'.$username, 0777);
if ($fp = fopen("/home/path/public_html/".$username."/index.php", "w")) {
fwrite($fp, $filecontent);
chmod("/home/path/public_html/".$username."/index.php", 0755);
fclose($fp);
}
I could've used that a couple of hours ago! Haha, I was able to figure it out on my own though! Thanks anyways, hopefully that'll alleviate some time for other users who wanted to do what I did; but of course I did mine the hard, "on-my-own" way... heh :p

hate
03-23-2005, 04:10 AM
I could've used that a couple of hours ago! Haha, I was able to figure it out on my own though! Thanks anyways, hopefully that'll alleviate some time for other users who wanted to do what I did; but of course I did mine the hard, "on-my-own" way... heh :p
I should have been a little faster lol sorry I was coding on something else.