views:

26

answers:

2

how to download folder from some ftp server into your server home directory and give to that directory rights? (like all files in this directoy have all or non rights...) not using special libs if it is possible...

how to do such thing?

+2  A: 
<?php
file_put_contents('./file.txt', file_get_contents('ftp://server/file.txt'));
?>

The FTP server must support passive mode (ref) and your web server must have allow_url_fopen set in the php.ini (ref).

To give rights use chmod('./file.txt', 0777) or whatever rights you need.

andr
+1 for clear concise explanation, supporting comments and elegant ref links
Smandoli
But ... this is for transferring text. I figured the question was about files. ?
Smandoli
I guess it's good for anything -- both file functions are binary safe, I just used a .txt file as an example.
andr
grate about file's (at leastone - it was what I realy needed - I get zip and unpac it) But Question was about "... download folder from ..." so I suppoused to get all folder not knowing what files are exactly in it....
Blender
A: 

I think you may want PHP's 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 which looks like a good tutorial as well as usable code:

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

Smandoli