Jump to content

Duplicating a master file


gerkintrigg

Recommended Posts

I wrote a script to automatically generate a folder with an index page in it using data from a database record, but it only operates when the administrator activates the record. I've worked out nearly all of it, but is there a simple way to copy the original contents of the master file, but leave the original intact?

 

I'm not getting any errors, and the directory is being created, but it's empty.

 

So-far I have:

 

$path_to_file=$root.$shop_name.'/index.php';
if(!file_exists($path_to_file)){
mkdir($root.$shop_name,'0777');
copy($root.'members/do-not-delete.php', $root.$shop_name.'/index.php');
}

 

I can't see anything wrong with the code and all the Google snippets seem to suggest this is the way to do it.

 

Help, please.

Neil

Link to comment
Share on other sites

I am using Mod Rewrite too, but this creates a blank page to work from so they can customise it themselves.

I'm fine with doing it this way and there are reasons for it which I won't go into now, but needless to say I need a subdirectory (a real one) for each new shop.The only issue is how to duplicate the file.

Link to comment
Share on other sites

You should check your error logs, and see if you get an error message returned.

Also, remove the quotes around the permissions. They prevent the mode from being parsed as an octal:

php > echo 0777;
511
php > echo intval ('0777');
777

 

Edited by Christian F.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.