Not sure if anyone here will be able to shed some light on this but Google isn't helping.
I have some PHP code that opens a connection to an FTP server (running Pure-FTPd), writes a few lines to a file, then closes the connection. In other words: $fh = fopen('ftp://user:pass@ftp.example.com/test.csv','w'); for ($i=0;$i<=100;$i++) fputs($fh, "blah blah blah\r\n"); fclose($fh);
The problem is that when I look at the uploaded file it's contents have been truncated. Putting a suitably long sleep() before the fclose "solves" this for some definition of "suitably long" but obviously isn't a real solution. Inserting an fflush($fh) makes no difference.
I'm not sure if this is a PHP issue (specifically with the FTP wrappers to fopen/fclose), or a generic FTP issue, or a problem specific to Pure-FTPd. I have however tried to two different servers running very different versions of Pure-FTPd with the same effects.
If there was a standard issue here I'd have found something with Google, surely? Otherwise I don't know where to go looking?