Answer the question
In order to leave comments, you need to log in
Why doesn't file_get_contents get file contents via ftp?
An FTP server is configured on the Ubuntu server. Everything is perfectly connected through the client. On the same server there is a site, it has a file ftp.php with the following content;
<?php
$ftphost = '91.2**.*11.**';
$ftpport = '21';
$ftpuser = 'user';
$ftppasswd = 'o$ofrJhjky4K+/`4';
$file = 'otchet.txt';
// Папка, которую нужно выводить
$folder = 'docs/otchet/2016';
$content = file_get_contents('ftp://'.$ftpuser.':'.$ftppasswd.'@'.$ftphost.'/'.$folder.'/'.$file);
echo ($content);
?>
Answer the question
In order to leave comments, you need to log in
The main mistake of developers is that they only know file_get_contents and try to do everything with it, up to cURL. Use standard tools for working with FTP: php.net/manual/ru/book.ftp.php , there is error control, and certificates, and everything you need. And yes, unlike file_get_contents they will say what is wrong.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question