ftp_get无法正常工作,没有错误

时间:2012-10-11 14:51:44

标签: php filezilla

如果我从root获取文件它可以工作,但是如果我想从文件夹中获取文件它会失败但显示“文件已成功下载”。

这是代码

$sourcefile = "test.doc";
$local_file = $_SERVER['DOCUMENT_ROOT'] . "/sites/default/files/" . "answerdoc" . $node->nid . $sourcefile; 
$remote_file = "test.doc";
$currPath = "documents";        


if (@ftp_login($conn_id, FTP_USER, FTP_PASS)) {

    // it works
    ftp_pasv($conn_id, true);               

    if (ftp_get($conn_id, $local_file , $remote_file, FTP_BINARY)) {
        drupal_set_message(t('file downloaded successfully'));
    } else {
        drupal_set_message(t('there was error'));
    }


    if(@ftp_chdir($conn_id,$currPath)){

        $answerdir ="Answer";
        // it does not work but shows "file downloaded successfully"
        if(@ftp_chdir($conn_id,$answerdir)) {   

            ftp_pasv($conn_id, true);

            if (ftp_get($conn_id, $local_file, $remote_file, FTP_BINARY)) {
                drupal_set_message(t('file downloaded successfully'));
            } else {
                drupal_set_message(t('there was error'));
            }


        }
    }
}

被修改

1 个答案:

答案 0 :(得分:2)

  1. 首先,从函数调用中删除“@”。
  2. 其次,请确保将错误报告设置为E_ALL。

    error_reporting(E_ALL);
    
  3. 检查浏览器输出和Web服务器错误日志。

  4. 这应该可以帮助您排除故障。