|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-01-24 09:28 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 19:00:01 2025 UTC |
Description: ------------ When I create a file using the FOPEN function and then try to change permissions on the file it says it cant be done because Bad File Descriptors. PHP version 5.1.6 Reproduce code: --------------- $conn_id = chmod_open(); $ourFileName = "testFile.txt"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle); function chmod_open() { // Use your own FTP info $ftp_user_name = 'vikoshos'; $ftp_user_pass = 'frath0pr'; $ftp_root = '/'; $ftp_server = 'localhost'; $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); return $conn_id; } function chmod_file($conn_id, $permissions, $ftpath) { echo "$ftpath"; if (ftp_site($conn_id, 'CHMOD ' . $permissions . ' ' . $ftp_root . $ftpath) !== false) { return TRUE; } else { return FALSE; } } chmod_file($conn_id, 0777, $ourFileName); Expected result: ---------------- Change the file mod to 777 Actual result: -------------- Warning: ftp_site() [function.ftp-site]: Could not change perms on newfile.txt: Bad file descriptor in code.php on line 168