I wrote Drupal module for viewing files from some directories. If files are stored on drupal folder "sites/default/files/someimages" or ftp folder "ftp://someftp.com/someimages/", all work fine! But if ftp is protected by user and password, error occured in my php module code:
warning: scandir(ftp://someftp.com/someimages/): failed to open dir: operation failed in /srv/www/vhosts/mysite.com/sites/all/modules/mymodule/mymodule.module on line 227.
How to accept permissions to my drupal module for opening ftp folders?
Can't you just add username and password like that? so you can authorise?
ftp://username:password@sld.domain.tld/path1/path2/
As altetnative, try to use function ftp_login
<?php
$ftp_server = "ftp.example.com";
$ftp_user = "foo";
$ftp_pass = "bar";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Connected as $ftp_user@$ftp_server\n";
} else {
echo "Couldn't connect as $ftp_user\n";
}
// close the connection
ftp_close($conn_id);
?>