FTP传输远程目录中的所有文件,并使用PHP调整权限 [英] FTP transfer all files in a remote directory, and tweak permissions, using PHP

查看:329
本文介绍了FTP传输远程目录中的所有文件,并使用PHP调整权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将文件夹从一些ftp服务器下载到我的服务器主目录,并授予该目录的权限(像这个目录中的所有文件都有全部或者没有权限)?



不使用特殊的库,如果可能的话。

解决方案

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

FTP服务器必须支持被动模式( ref ),您的Web服务器必须在php中设置 allow_url_fopen 。 ini( ref )。



给予权限使用 chmod('./ file.txt',0777)或您需要的任何权限。 / p>

How can I download folder from some ftp server into my server home directory and give to that directory rights (like all files in this directory have all or no rights)?

Not using special libraries if it is possible.

解决方案

<?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.

这篇关于FTP传输远程目录中的所有文件,并使用PHP调整权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆