简体   繁体   English

在php中复制,移动然后重命名文件

[英]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.我正在处理我网站的会员注册部分,当会员注册时,它会在 images/useravatars/(username) 中创建一个文件夹,但在文件夹 images/useravatars/ 中有一个 001.png 文件,我想复制、重命名(到用户名)并粘贴到新成员新创建的文件夹中。 How is this done in php?这是如何在 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);基本上你想要做的只是一个步骤,你提供001.png文件的路径,然后使用copy(defaultImgPath, newUserImgPath);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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