note 102061 added to function.ftp-fput
| From: | JulienLaumond at osu1 dot php dot net | Date: | Tue, 25 Jan 2011 19:48:21 +0000 |
| Subject: | note 102061 added to function.ftp-fput | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-176301@lists.php.net to get a copy of this message | ||
daniel-marschall function don't clone the directory and subdirectories structure, this version
is functional on a windows php serveur.
Brutal but funccional...
I personaly use '/' as $origin, this may be dangerous if the user is not Locked in its
default directory... ROOT access :-{
<?php
function ftp_uploaddirectory($conn_id, $local_dir, $remote_dir)
{
global $origin;
ftp_mkdir($conn_id, $remote_dir);
ftp_chdir($conn_id, $remote_dir);
$handle = opendir($local_dir);
while (($file = readdir($handle)) !== false)
{
if (($file != '.') && ($file != '..'))
{
if (is_dir($local_dir.$file))
{
ftp_chdir($conn_id, $origin);
ftp_uploaddirectory($conn_id, $local_dir.$file.'/', $remote_dir.$file.'/');
}
else
$f[] = $file;
}
}
closedir($handle);
if (count($f))
{
sort($f);
ftp_chdir($conn_id, $origin);
ftp_chdir($conn_id, $remote_dir);
foreach ($f as $files)
{
$from = fopen("$local_dir$files", 'r');
ftp_fput($conn_id, $files, $from, FTP_BINARY);
}
}
//ftp_cdup($conn_id);
}
$origin='THE currentdir of the $conn_id';
$conn_id = @ftp_connect($server);
@ftp_login ($conn_id, $user, $password);
ftp_pasv($conn_id, true);
ftp_uploaddirectory($conn_id, $local_dir, $remote_dir);
@ftp_quit($conn_id);
?>
----
Server IP: 130.206.1.5
Probable Submitter: 213.37.6.93
----
Manual Page -- http://www.php.net/manual/en/function.ftp-fput.php
Edit -- https://master.php.net/note/edit/102061
Del: integrated -- https://master.php.net/note/delete/102061/integrated
Del: useless -- https://master.php.net/note/delete/102061/useless
Del: bad code -- https://master.php.net/note/delete/102061/bad+code
Del: spam -- https://master.php.net/note/delete/102061/spam
Del: non-english -- https://master.php.net/note/delete/102061/non-english
Del: in docs -- https://master.php.net/note/delete/102061/in+docs
Del: other reasons-- https://master.php.net/note/delete/102061
Reject -- https://master.php.net/note/reject/102061
Search -- https://master.php.net/manage/user-notes.php