使用PHP - XAMPP将文件或目录移动到C:Windows


Move file or directory to C:Windows using PHP - XAMPP

我被困在一个脚本。我正在开发一个基于php的应用程序,客户端可以在安装后使用XAMPP服务器离线使用它。我想在安装过程中创建一个名为lic.txt的文件,我也设法创建了它..

我面临的唯一问题是我无法将文件移动到C:'Windows文件夹中,我只想将其移动到那里。我能够将文件移动到XAMPP文件夹中的任何地方,该文件夹安装在C:'XAMPP

代码是这样的:

  <?php
    $filename = 'lic.txt';
$data = 'License Registered Successfully';
$newlocation = 'C:''Windows''lic.txt';
    $fh = fopen($filename, 'w'); 
     fwrite($fh, $data); 
     fclose($fh);
    rename($filename, $newlocation);
    ?>

当我运行文件时,它给了我错误

Warning: rename(lic.txt,C:'Windows'lic.txt): Access is denied. (code: 5) in C:'xampp'htdocs'latest'fwrite.php on line 9

我知道这是因为文件夹权限不足,但我已经搜索了整个网络,但找不到任何解决方案。有没有人能帮我解决这个问题?

谢谢…

首先,这不是PHP设计的应用程序类型。还有更好的选择。

为了读取或写入windows目录,您需要以管理员权限运行XMAPP。这可能会使它很难部署到任何客户。