note 94903 added to function.ftp-chmod

From: Date: Wed, 02 Dec 2009 07:02:22 +0000
Subject: note 94903 added to function.ftp-chmod
Groups: php.notes 
Request: Send a blank email to php-notes+get-163474@lists.php.net to get a copy of this message
Here's the code that will create directories recursively. # Recursively create directory via ftp function CreateDirFtp($ftpConn, $path, $mode) { $mode = octdec( str_pad($mode,4,'0',STR_PAD_LEFT) ); # Get current dir $currentDir = ftp_pwd($ftpConn); # Change dir to root if path is from root$ if($path[0] == '/') ftp_chdir($ftpConn, '/'); # Split path $dirArray = explode('/', $path); # Begin creating directories recursively foreach($dirArray as $dir) { if(strlen($dir) > 0) { echo ftp_pwd($ftpConn) . '/' . $dir; ftp_mkdir($ftpConn, str_replace(" ", "_", $dir)); ftp_chmod($ftpConn, $mode, $dir); # Quit creation if chdir fails if(ftp_chdir($ftpConn, str_replace(" ", "_", $dir)) == false) break; } } # chdir to originating dir ftp_chdir($ftpConn, $currentDir); } ---- Server IP: 69.147.83.197 Probable Submitter: 125.60.241.202 ---- Manual Page -- http://www.php.net/manual/en/function.ftp-chmod.php Edit -- https://master.php.net/note/edit/94903 Del: integrated -- https://master.php.net/note/delete/94903/integrated Del: useless -- https://master.php.net/note/delete/94903/useless Del: bad code -- https://master.php.net/note/delete/94903/bad+code Del: spam -- https://master.php.net/note/delete/94903/spam Del: non-english -- https://master.php.net/note/delete/94903/non-english Del: in docs -- https://master.php.net/note/delete/94903/in+docs Del: other reasons-- https://master.php.net/note/delete/94903 Reject -- https://master.php.net/note/reject/94903 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#163474) next »