note 64290 deleted from function.chmod by googleguy

From: Date: Tue, 22 Oct 2013 14:58:06 +0000
Subject: note 64290 deleted from function.chmod by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197249@lists.php.net to get a copy of this message
Note Submitter: neil at 11 out of 10 ---- 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.

« previous php.notes (#197249) next »