开发者

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.

I'm simply using this code in a loop to get all the files in a directory.

ftp_get($this->co开发者_开发技巧nn_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.

edit: Oddly enough, closing the connection, sleeping 3 seconds, and creating a new connection between each get yields the same results...

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. I'll just ignore that error.


Try using ftp_fget instead and saving the file before trying to get another one.


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. You shouldn't have to do that for php but I would try it just to rule it out as a possible issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜