在php中将文件从一个复制到另一个 [英] Copy files from one to another in php not working
问题描述
试图在 PHP
中将文件从一个目录复制
到另一个目录,但不是复制.
Trying to copy
files from one directory to another in PHP
, but it is not copying.
我的代码:
<?php
copy('lang.php', '../lang.php'); //lang.php
copy('db_doc.php', '../me/db.php'); //db.php
copy('vdb_doc.php', '../me/vdb.php'); //db.php
copy('db_log.php', '../dbconfig.php'); //dbconfig.php
copy('inser_sql.php', '../inser_sql.php'); //inser_sql.php
echo "Installation Successful! <a href='../'>Go Back</a>";
?>
推荐答案
错误应该在这里:
1:尝试检查文件夹权限
(如何使用权限?请参见 http://php.net/manual/en/function.chmod.php )
1: Try to check FOLDER PERMISSION
(How to play with Permission ? see http://php.net/manual/en/function.chmod.php )
2:父文件夹
不存在(您正在使用 ../
).
2: Parent folder
does not exist (you are using ../
).
Copy()的工作方式:
bool copy ( string $source , string $dest [, resource $context ] )
将文件 source
的副本复制到 dest
.
如果目标文件已经存在,它将被覆盖.
If the destination file already exists, it will be overwritten.
如何设置权限(Linux)?:
如果使用的是VPS/Dedicated,请转到Linux终端并使用命令 sudo chmod 755 -R folder_name
.如果您使用共享主机,只需转到 www
文件夹并使用 UI
Go to your Linux Terminal and use command sudo chmod 755 -R folder_name
, if you are using VPS/Dedicated. if you are using Shared Hosting simply go to www
folder and set permission by following given steps using UI
这篇关于在php中将文件从一个复制到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!