Reputation: 33
How can I return to the ftp users root folder. In this example it is /isi/ in my home/user/ dir.
$location = $order;
$real_location = $workflow_location =$leverancier;
if (!@ftp_chdir($ftp_conn, $real_location)) {
ftp_mkdir($ftp_conn, $real_location);
}
foreach($maps as $map) {
$real_location = $real_location . '/' . $map;
$workflow_location = $workflow_location . '~' . $map;
if (!@ftp_chdir($ftp_conn, $real_location)) {
ftp_mkdir($ftp_conn, $real_location);
ftp_chdir($ftp_conn, $real_location);
}
}
// ISI is the root folder
if (ftp_chdir($ftp_conn, '/isi/')) {
echo "ftp_chdir successful\n";
} else {
echo "ftp_chdir not successful\n";
}
exit;
---------------------------------------------------------- EDIT ----------------------------------------------------------------
Not realy a clean way to do it, but putting this after the code is poster above did the trick. I counted the folders, this way I did know how many times I've to use the ftp_cdup function.
$i = count($maps);
$i++;
while($i > 0) {
ftp_cdup($ftp_conn);
$i--;
}
---------------------------------------------------------- EDIT2 ---------------------------------------------------------------
Other solution:
ftp_chdir($ftp_conn, '~');
Upvotes: 2
Views: 2620
Reputation: 8517
On Linux machines You can address current user's home directory as ~
.
So, one of the possible solutions would be just using ftp_chdir($ftp_conn, '~');
.
still lookin for official documentation entry for ~, ., .. etc.
Upvotes: 2