更改ftp_get下载目录

时间:2017-12-21 07:09:44

标签: php

我使用以下代码使用ftp下载

$local_file = $_GET['u'];
$server_file = $_GET['u'];
    $ftp_host = '';
    $ftp_user_name = '';
    $ftp_user_pass = '';


$ftp_conn = ftp_connect($ftp_host) or die("Could not connect to $ftp_host");
$login = ftp_login($ftp_conn, $ftp_user_name, $ftp_user_pass);
ftp_pasv($ftp_conn,true);
ftp_chdir($ftp_conn, '');
$file_list = ftp_nlist($ftp_conn, ".");
//var_dump($file_list);
//var_dump(ftp_get($conn_id, $local_file, $server_file, FTP_BINARY));
if (ftp_get($ftp_conn, $local_file, $server_file, FTP_BINARY)) {
echo "Successfully written to $local_file\n";
}
else {
    echo "There was a problem\n";
}

我成功写入文件名但我似乎无法在我的电脑上找到该文件。你是否可以改变文件下载的位置。

1 个答案:

答案 0 :(得分:1)

传递绝对路径(而不是"myfile.txt"尝试"/home/user/path/to/yourfile.txt"