How to use SplFileObject() with FTP?

258 Views Asked by At

This code runs very well with fopen:

<?php 

    $filename = "ftp://$ftp_user_name:$ftp_user_pass@$ftp_server/testes/TJ_IDA.TXT";
    $handle = fopen($filename, "r");
    $contents = fread($handle, filesize($filename));
    fclose($handle);

    echo $contents;

But when I try with SplFileObject:

$file = new SplFileObject($filename,"r");

I got this error:

Warning: Unknown: FTP server error 426:426 Failure writing network stream. in Unknown on line 0

Is there another way to use SplFileObject with FTP?

0

There are 0 best solutions below