Php ftp\u无法工作,没有错误

Php ftp\u无法工作,没有错误,php,filezilla,Php,Filezilla,若我从根目录获取文件,它会工作,但若我想从文件夹获取文件,它会失败,但会显示“文件下载成功” 这是代码 $sourcefile = "test.doc"; $local_file = $_SERVER['DOCUMENT_ROOT'] . "/sites/default/files/" . "answerdoc" . $node->nid . $sourcefile; $remote_file = "test.doc"; $currPath = "documents";

若我从根目录获取文件,它会工作,但若我想从文件夹获取文件,它会失败,但会显示“文件下载成功”

这是代码

$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'));
            }


        }
    }
}
编辑

  • 首先,从函数调用中删除“@”
  • 其次,确保您的错误报告设置为E_ALL

    error_reporting(E_ALL);
    
  • 检查浏览器输出和web服务器错误日志


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

    您正在使用
    @
    来抑制错误,所以难怪您没有看到任何错误。删除
    @
    s$currPath设置为什么?$local_文件设置为什么?哦,一个地方使用$sourcefile,另一个地方使用$remote\u file。。里面还有什么?抱歉我在测试,我编辑了我的资料