FTP transfers all files in a remote directory and sets permissions using PHP

How to upload a folder from some ftp server to my server’s home directory and grant rights to this directory (for example, all files in this directory have all rights or not)?

Do not use special libraries if possible.

0
source share
2 answers
<?php file_put_contents('./file.txt', file_get_contents('ftp://server/file.txt')); ?> 

The FTP server should support passive mode ( ref ), and your web server should have allow_url_fopen set to php.ini ( ref ).

Grant rights to use chmod('./file.txt', 0777) or any other rights that you need.

+3
source

I think you may need PHP functions for FTP, such as ftp_nlist and ftp_nb_get :

http://www.w3schools.com/PHP/php_ref_ftp.asp

I also found this resource that looks like a good tutorial as well as useful code:

http://www.raditha.com/php/ftp/pasv.php

+1
source

Source: https://habr.com/ru/post/885825/


All Articles