我的PHP代码显示和错误,我真的不知道如何解决它。
Warning: file_put_contents(/ecc/.htpasswd): failed to open stream: No such file or directory in /storage/ssd4/683/2921683/public_html/admin/htpasswd.php on line 19
我的代码:
<?php
require('assets/head.php');
if ($_POST['perm'] == 0) {
$dir = '/ecc/.htpasswd';
}
else {
$dir = '.htpasswd';
}
$user = strtoupper($_POST['grade']).strtoupper($_POST['nfamille']);
$nom = $_POST['nfamille'].' '.$_POST['pnom'];
// Password to be encrypted for a .htpasswd file
$clearTextPassword = $_POST['mdp'];
$ligne = count(file('.htpasswd')) + 1;
// Encrypt password
$password = crypt($clearTextPassword, base64_encode($clearTextPassword));
$file = $user.':'.$password."\n";
echo $file;
file_put_contents($dir, $file,FILE_APPEND);
$req = $bdd->prepare('INSERT INTO CCPC(ligne, grade, nom, perm, prefix)
VALUES(?, ?, ?, ?, ?)');
$req->execute(array($ligne, $_POST['grade'], $nom, $_POST['perm'], $user,));
?>
感谢您的帮助 编辑:忘了说我的php文件在管理文件夹
答案 0 :(得分:0)
将/ecc/.htpasswd
更改为../ecc/.htpasswd