I am trying to list all the files from a certain directory in a remote SFTP server as download links so that the user can have the option of downloading those files. So far, I have been able to read and list all the files from a specific directory as download links, but when I try to actually download a file by right clicking and choosing save link as... I get a "Failed - No File" message. Picture of my results
<?php
$connection = ssh2_connect('url', 22);
ssh2_auth_password($connection, username, password);
$sftp = ssh2_sftp($connection);
$sftp_fd = intval($sftp);
if ($handle = opendir("ssh2.sftp://$sftp_fd/path/to/remote/dir/")) {
while (($entry = readdir($handle)) !== false) {
if ($entry == "." || $entry == "..") { continue; }
echo '<a href="/path/to/remote/dir/' .$entry. '">' .$entry. '<br>'.'</a>';
}
closedir($handle);
}
?>