Thorsten
Thorsten

Reputation: 186

php file_get_contents FTP

I'm trying to get a file from a public ftp server via file_get_contents.

$url = 'ftp://ftp.server.de/my_file.txt';
echo file_get_contents($url);

I get the following error:

file_get_contents(): connect() failed: No route to host

allow_url_fopen is enabled.

What could be the problem?

Upvotes: 1

Views: 5479

Answers (2)

Thorsten
Thorsten

Reputation: 186

It was a firewall issue.

The PHP ftp wrapper uses only passive mode. So all ports have to be open.

Upvotes: 3

Biju s
Biju s

Reputation: 430

$url = 'www://ftp.server.de/my_file.txt';



$file = file_get_contents($url, true);

Try this

Upvotes: -1

Related Questions