note 112399 added to function.ftp-mkdir

From: Date: Tue, 11 Jun 2013 20:32:35 +0000
Subject: note 112399 added to function.ftp-mkdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-195135@lists.php.net to get a copy of this message
Here's the correct code for making recursive directories: <?php // function function ftp_mksubdirs($ftpcon,$ftpbasedir,$ftpath){ @ftp_chdir($ftpcon, $ftpbasedir); // /var/www/uploads $parts = explode('/',$ftpath); // 2013/06/11/username foreach($parts as $part){ if(!@ftp_chdir($ftpcon, $part)){ ftp_mkdir($ftpcon, $part); ftp_chdir($ftpcon, $part); //ftp_chmod($ftpcon, 0777, $part); } } } // usage $path_of_storage = '/var/www/uploads'; $newftpdir = '2013/06/11/username'; $conn_id = ftp_connect($ftpserver); ftp_login($conn_id, $login, $pass); ftp_mksubdirs($conn_id,$path_of_storage,$newftpdir); ftp_close($conn_id); ?> ---- Server IP: 69.147.83.199 Probable Submitter: 88.175.82.99 ---- Manual Page -- http://php.net/manual/en/function.ftp-mkdir.php Edit -- https://master.php.net/note/edit/112399 Del: integrated -- https://master.php.net/note/delete/112399/integrated Del: useless -- https://master.php.net/note/delete/112399/useless Del: bad code -- https://master.php.net/note/delete/112399/bad+code Del: spam -- https://master.php.net/note/delete/112399/spam Del: non-english -- https://master.php.net/note/delete/112399/non-english Del: in docs -- https://master.php.net/note/delete/112399/in+docs Del: other reasons-- https://master.php.net/note/delete/112399 Reject -- https://master.php.net/note/reject/112399 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195135) next »