Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

Php copy and paste files on server? move files on server?

0

55 views

I was wondering how possible it is with PHP to copy a file from one directory on a server and paste it into another. I have a system that when a user registers creates a sub directory called the same as there username, I then want to copy a file called profile.php from a sub directory called users and paste it in the new directory with the name of the user?

asked March 26, 2011 1:01 pm CDT
Lit
posted via StackOverflow

3 Answers

4
 

You shouldn't do it this way.

There must be just one profile.php, serving all users. That's the way how PHP works. It is used to create dynamical sites, producing dynamical content based on user's input.

So, based on entered username, it should display particular user's info. One script to serve all users.

answered March 26, 2011 1:23 pm CDT
2
 

The PHP copy() function just copies a file from one directory to another.

http://php.net/manual/en/function.copy.php

answered March 26, 2011 1:23 pm CDT
0
 

As Col. Shrapnel suggest, you shouldn't copy the profile.php for each user. That will be hard to maintain, and unnecessary duplication. But here's how you can make subdirectories for each of your users.

<?php

    $username = 'me';

    if(userregisters) {
    mkdir('/file/to/path/{$username}');
    } 

answered March 26, 2011 1:23 pm CDT

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions