Following code seems to execute OK:
<?
$file = fopen('ftp://user:pass@somewhere.com/work/a1.bla/', "w");
if (!$file)
echo "can't do that";
else
echo 'Ok<br>';
// Write the data here
fwrite ($file, "abra kadabra\n");
fclose ($file);
echo 'done';
?>
However, when I check on the ftp server, there is no file. Checking ftp server session log, I have the following:
331 Password required for lado.
PASS ********
logged in.
230 User lado logged in.
TYPE I
200 Type set to I.
SIZE /work/a1.bla/
550 No such file or directory.
EPSV
500 Unknown command.
PASV
227 Entering Passive Mode (192,168,1,16,21,200).
STOR /work/a1.bla/
asked to upload '\work\a1.bla\' in 'D:\' --> Access allowed.
QUIT
221 Bye bye ...
aborted uploading '\work\a1.bla\' in 'D:\' - (06:30:43 - -0,001 KB - 0,000 KBytes/s).
disconnected. (00:00:00)
It turns out that the file transfer was initiated OK but the PHP did not wait till transfer was completed but finished the script, thus colsing the FTP connection and aborting the transfer.
Browsing the archives trying to find some kind of solution did not help me so far.
Anybody out there with an idea, how do avoid this from happening?
Regards, Vladimir