简体   繁体   中英

copy, move then rename file in php

I am working on the member registration section of my site and when a member registers it creates a folder in images/useravatars/(username) but in folder images/useravatars/ there is a 001.png file which I want to copy, rename (to the users name) and paste to the new members newly created folder. How is this done in php? It is a default avatar image which gets assigned to all newly registered members.

Take a look at the copy function.

bool copy ( string $source , string $dest [, resource $context ] )

Basically what you want to do is a single step, you provide the path of the 001.png file and then use copy(defaultImgPath, newUserImgPath);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM