I am trying to allow users to download files from FTP server mounted using CurlFtpfs on Cent OS 7.9.
My mounting configuration is as following :
curlftpfs#user:password@server/ebook /var/ebook/books fuse allow_other,uid=webuser,gid=psaserv,umask=0000 0 0
The webuser is the same one how owns httpd folder where the webiste file remains
as for the download code is
<?php
$filelocation='/var/ebbok/x.pptx';
$filename = basename($filelocation);
if (file_exists($filelocation)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header("Content-Type: application/force-download");
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filelocation));
ob_clean();
flush();
readfile($filelocation);
exit;
}
?>
I made sure the x.pptx file exists and is in the folder, also working with SSH I can see the files and even manipulated them.
However, the file_exists
function always returns false and I cannot access the folder or files in it in read nor write mode.
I have a similar setup on another server but using SMB and java Spring and that one working correctly.
I cannot use SMB on this server due to the fact that both servers are on 2 sperate networks, and I believe FTP is better in this situation