I want to create new file into


I try to run PHP script,but the file not created

This is my code:

$sftp = new Net_SFTP('localhost');
if (!$sftp->login('muhammad', 'Kaynetc0m')) {
exit('Login Failed');
$sftp->chdir( '/etc/freeradius' );
$sftp->put("sql.conf", $txt,NET_SFTP_RESUME);

I want to append text to sql.conf file into freeradius directory

this is the output:

 ls -l /etc/freeradius/sql.conf
-rw-r----- 1 muhammad freerad 12549 Eyl 25 15:27 /etc/freeradius/sql.conf

In other hands when I execute this code on other path and file it executed nice

  • Is this code ran from within freeradius? Sep 27, 2017 at 9:20
  • Possible user Muhammad should have appropriate rights to modify directory /etc/freeradius/ Cause when you adding file to directory - you modifying directory; when you append to file via ftp - you are deleting file and creating new one with new content. Sep 27, 2017 at 22:15
  • How do you run the php script? If you call it from a webserver (e.g. apache) than not you but the server needs acces to this file (chown www-data:freerad /etc/freeradius/sql.conf)
    – derHugo
    Nov 14, 2017 at 16:01


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.