将文件复制到另一个文件夹PHP [英] Copy Files to another folder PHP

查看:619
本文介绍了将文件复制到另一个文件夹PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,最近我在一个小型社交网络上工作,我陷入了初学者失败的状态:(

So, recently I am working on a small social network, and I stuck at a beginner-fail :(

创建新用户后,将在当前文件夹(/Users)中创建一个新文件夹-类似于用户名.在当前文件夹(/用户)中还有一个名为PATTERN的文件夹,其中包含index.php.

When a new User is created, a new FOLDER - named like the User - is created in the current folder (/Users). In the current folder(/Users) is also a folder named PATTERN, where a index.php is included.

使用mkdir($Username, 0777)创建新用户时,我还想将index.php从PATTERN文件夹(/PATTERN)复制到新的User文件夹(/$ Username)中.

When a new user is created with mkdir($Username, 0777) I also want to COPY the index.php from the PATTERN-Folder (/PATTERN) into the new User folder (/$Username).

它只是在我的尝试中没有复制-您将如何做?

It just doesn't copy in my tries - how would you do that?

推荐答案

您可以使用复制()使用PHP复制文件:

You can use copy() to copy a file with PHP:

if (!copy('PATTERN/index.php', $Username.'/index.php')) {
    echo "failed to copy file...";
}

如果这不起作用,则可能是您的代码,访问权限或其他问题.没有您的代码和错误消息的准确描述(如果有),将很难为您提供帮助.

If this does not work, you might have a problem with your code, access rights, or something else. Without your code and the exact description of the error message (if any) it will be hard to help you.

这篇关于将文件复制到另一个文件夹PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆