Friday, January 26, 2024

[SOLVED] how to get the file permission for a single file in php ftp function

Issue

This is the function I'm using at the moment:

ftp_site($conn_id, 'CHMOD 0777 ./httpdocs/test.txt');

How can I get the permissions (read, write, etc) for a single file?

// Set up basic connection
$ftp_server = "test.com";
$conn_id = ftp_connect($ftp_server,21);

// Login with username and password
$ftp_user_name = "user";
$ftp_user_pass = "pass";
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_pasv($conn_id, true);

//ftp_site($conn_id, 'CHMOD 0777 ./httpdocs/test.txt');

Solution

Update

How about - http://www.php.net/manual/en/function.ftp-rawlist.php - seems you can get the file permissions this way instead ... though this won't give you it in numerical form, you would be able to get the permissions...

--- Original ---

You can get the current file permissions using the PHP function fileperms()

See http://www.php.net/fileperms for more details



Answered By - MrJ
Answer Checked By - Dawn Plyler (WPSolving Volunteer)