Reputation: 539
I have a PHP script to sign up people as a member. After inserting their data in the database, a folder is created inside the 'user' folder with their name ($u). After creating the file, I want to copy the image thumbnail.png from the folder mydomain/img/thumbnail.png to mydomain/user/$u/dummypic.png. The signup process is successful and I get no error messages. But when I look in the created folder, the file is not copied there, it's empty.
Anyone who can see what's wrong with the code I have?
// xxx code of inserting in DB xxx
// Create directory(folder) and copy the dummy avatar picture
if (!file_exists("user/$u")) {
mkdir("user/$u", 0755);
copy('img/dummypic.png', 'user/$u/dummypic.png');
}
Upvotes: 1
Views: 116
Reputation: 2059
Use $u in double quotes "". Like below:
copy('img/dummypic.png', "user/$u/dummypic.png");
Upvotes: 3