PHP ftp_get could not open the stream when trying to load a file

I am trying to get the browser to download a file from an FTP server, but no matter what I try, I get this error:

Warning: ftp_get(taak4.docx) [function.ftp-get]: failed to open stream: Permission denied in /home/jamesmr117/domains/notepark.be/public_html/classes/taak.php on line 231

Warning: ftp_get() [function.ftp-get]: Error opening taak4.docx in /home/jamesmr117/domains/notepark.be/public_html/classes/taak.php on line 231

However, I am sure that my FTP server is 100% working, as file uploading works correctly. I also installed each folder in chmod 777. Does anyone know what the problem is?

My php code is:

$local_file="taak4.dockx";
$server_file="taak4.dockx";
ftp_get($FTPClient->connectionId, $local_file, $server_file, FTP_BINARY);

Thanks in advance!

+4
source share
2 answers

You must specify the full path to the file. For example:

/var/home/victor/files/taak4.dockx

Use $_SERVER['DOCUMENT_ROOT']to get the root path of the document.

+1
source

$local_file. . : chmod 777 /test $local_file /test/taak4.docx.

0

All Articles