简体   繁体   English

PHP ftp_nlist卡在Rootfolder上

[英]PHP ftp_nlist stuck on Rootfolder

I'm having a very strange Problem with a new Script of mine. 我的新脚本出现了一个非常奇怪的问题。 It's just intended to list all files in a specific Folder but from ftp_nlist all i get in return are the folders located on the Root of the FTP! 它仅用于列出特定文件夹中的所有文件,但从ftp_nlist中得到的所有信息都是位于FTP根目录上的文件夹!

Here's a snipped of the code 这是一段代码

<?php
  $ftpServer = "192.168.10.190";
  $ftpUser = "user1";
  $ftpUser = "somePass";
  $remoteFilePath = "/SomeFolder/";

  $conn_id = ftp_connect($ftpServer) or die("<span style='color:#FF0000'><h2>Couldn't connect to $ftpServer</h2></span>");
  $login_result = ftp_login($conn_id, $ftpUser, $ftpPass) or die("<span style='color:#FF0000'><h2>You do not have access to this ftp server!</h2></span>");
  $files = ftp_nlist( $conn_id, $remoteFilePath );
  echo print_r($files)."<br>";
?>

Anyone with an Idea what is going on?! 任何有想法的人怎么了?

Solution

I've found it out on my own. 我自己找到了。 All i had to do was putting the ftp_nlist in a if clause that changed to the desired directory ;) 我要做的就是将ftp_nlist放在一个if子句中,该子句已更改为所需的目录;)

Try 尝试

$remoteFilePath = "./SomeFolder/";

with the dot for explicitly referring to the current directory. 带点的用于显式引用当前目录。

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

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