简体   繁体   English

如何通过php在ftp服务器上上传目录

[英]how to upload directories on ftp server via php

M a junior php developer, I am stucked in a problem that how to upload a whole directory containing several files and subfolders via php script to ftp server.. I have checked alot of method but none is working.. let I have a folder named "abc" and it contains many files and subfolders. 作为一名初级php开发人员,我陷入了一个问题,即如何通过php脚本将包含多个文件和子文件夹的整个目录上载到ftp服务器。.我检查了很多方法,但是都没有用..让我有一个名为的文件夹“ abc”,它包含许多文件和子文件夹。 I want to transfer it via php script using a loop which further searches for subfolders and files in subfolders of parent folder.. I used readdir() but it only geting sub directries.. Let me know the full step by step coding for that.. Thanks in advance...:) 我想通过一个循环使用php脚本来传输它,该循环进一步在父文件夹的子文件夹中搜索子文件夹和文件。我使用了readdir(),但它仅获得了子目录。 。 提前致谢...:)

Try this. 尝试这个。

foreach (glob("/abc/*.*") as $filename)
   ftp_put($ftp_stream, basename($filename) , $filename, FTP_BINARY);

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM