我在 WordPress/Woocommerce 中使用以下代码:
function generatePassword($length = 6) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$pass = '';
for ($i = 0; $i < $length; $i++) {
$pass .= $characters[rand(0, $charactersLength - 1)];
}
return $pass;
}
$password = generatePassword();
$data = "\n" . $password . ',' . time();
$test = 'http://advokatami.bg/ot/a/docs/test/test.txt';
$file = fopen($test,"a");
fwrite($file,$data);
fclose($file);
除了必须写入文件的最后部分之外,它都可以工作。你能告诉我代码有什么问题吗?我尝试更改CHMOD,但没有成功。
您必须提供服务器中实际文件位置路径的 Web 服务器路径,而不是 url。
$test = 'http://advokatami.bg/ot/a/docs/test/test.txt';
将其替换为服务器路径
$test = '<location_of_your_webroot_folder_in_server>/ot/a/docs/test/test.txt';
确保test
具有公开读写的权限。
如何检查您的文件夹路径?
1) Make test.php
文件输入ot
包含以下代码的文件夹
<?php
echo dirname(__FILE__);
die();
2)上传到ot
folder.
3)从浏览器执行文件http://advokatami.bg/ot/test.php
4)复制之前的路径\ot\....
并将其替换为<location_of_your_webroot_folder_in_server>
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)