简体   繁体   English

PHP-ftp_get仅工作一次

[英]PHP - ftp_get only works once

I'm connecting to an ftp server that I have no control over, and I'm pretty sure is using something old and outdated due to other issues I've run into. 我正在连接到我无法控制的ftp服务器,并且我可以确定由于我遇到的其他问题,我使用的是旧的和过时的东西。

I'm simply using this code in a loop to get all the files in a directory. 我只是在循环中使用此代码来获取目录中的所有文件。

ftp_get($this->conn_id, $remote, $local, FTP_ASCII);

The first time all goes well, but after that I get this error thrown for each file I try to get: "There is already an active transaction" 第一次一切都很好,但是此后,我尝试为每个文件抛出此错误:“已经有一个活动事务”

I've tried both passive & active, as well as a nonblocking get with no luck. 我已经尝试过被动和主动,以及没有阻碍的运气。 It's the exact same code I use to connect to other FTP servers and get files with no problem. 这是我用来连接其他FTP服务器并毫无问题地获取文件的完全相同的代码。

edit: Oddly enough, closing the connection, sleeping 3 seconds, and creating a new connection between each get yields the same results... 编辑:奇怪的是,关闭连接,休眠3秒钟,并在每个get之间创建一个新连接会产生相同的结果...

EDIT: Solved. 编辑:解决。 Turns out that despite the errors, the files are still being got. 事实证明,尽管有错误,仍在获取文件。 The catch block was just catching the error so I didn't realize it. catch块只是在捕获错误,所以我没有意识到。 I'll just ignore that error. 我将忽略该错误。

请尝试使用ftp_fget并保存文件,然后再尝试获取另一个文件。

It seems like "There is already an active transaction" may mean it is still transfering data when you try to use that connection again. 似乎“已经有一个活跃的事务”可能意味着当您再次尝试使用该连接时,它仍在传输数据。 Maybe use a sleep() function after puts and gets to give the transaction time to finish and see if that makes a difference. 也许在放置之后使用sleep()函数来给事务时间完成,看看是否有区别。 You shouldn't have to do that for php but I would try it just to rule it out as a possible issue. 您不必为php做到这一点,但我会尝试将其排除为可能的问题。

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

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