note 64290 added to function.chmod

From: Date: Tue, 11 Apr 2006 19:20:42 +0000
Subject: note 64290 added to function.chmod
Groups: php.notes 
Request: Send a blank email to php-notes+get-107793@lists.php.net to get a copy of this message
If you get a warning like chmod(): Operation not permitted in /home/folder/public_html/admin/includefiles/fileupload.php on line 24 You can use the ftp_site() function to send a CHMOD command through. <?php $ftp_details['ftp_user_name'] = $row['username']; $ftp_details['ftp_user_pass'] = $row['password']; $ftp_details['ftp_root'] = '/public_html/'; $ftp_details['ftp_server'] = 'ftp'.$_SERVER['HTTP_HOST']; function chmod_11oo10($path, $mod, $ftp_details) { // extract ftp details (array keys as variable names) extract ($ftp_details); // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // try to chmod $path directory if (ftp_site($conn_id, 'CHMOD '.$mod.' '.$ftp_root.$path) !== false) { $success=TRUE; } else { $success=FALSE; } // close the connection ftp_close($conn_id); return $success; } ?> The key thing to remember is that the document root and the ftp root are not the same. e.g. document root may be "/home/folder/public_html/" but the ftp root might be "/public_html/" Hope this helps someone. You might need this solution if you are on a shared server. ---- Server IP: 85.116.0.130 Probable Submitter: 81.179.39.220 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.chmod.php Edit -- http://master.php.net/note/edit/64290 Del: integrated -- http://master.php.net/note/delete/64290/integrated Del: useless -- http://master.php.net/note/delete/64290/useless Del: bad code -- http://master.php.net/note/delete/64290/bad+code Del: spam -- http://master.php.net/note/delete/64290/spam Del: non-english -- http://master.php.net/note/delete/64290/non-english Del: in docs -- http://master.php.net/note/delete/64290/in+docs Del: other reasons-- http://master.php.net/note/delete/64290 Reject -- http://master.php.net/note/reject/64290 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#107793) next »