SamH
SamH

Reputation: 1258

FtpOpenFile returns nil instead of file handle when uploading

I'm transferring a file using ftp in Delphi.

I am able to connect to the ftp account ok but when I try and upload a file the FtpOpenFile function returns nil instead of a handle the file to be uploaded.

hintfile := FtpOpenFile(hintconnect,PChar(tgtfn),GENERIC_WRITE,FTP_TRANSFER_TYPE_BINARY,0);

If I log into the ftp site using an ftp client application and exactly the same credentials I can upload the file without a problem.

Any suggestions appreciated.

Upvotes: 0

Views: 1512

Answers (2)

Marco van de Voort
Marco van de Voort

Reputation: 26358

Try adding INTERNET_FLAG_PASSIVE to your Internetopen call, see also

http://etutorials.org/Programming/Pocket+pc+network+programming/Chapter+2.+WinInet/File+Transfer+Protocol+FTP/

Upvotes: 0

user205036
user205036

Reputation:

Try to get the last error, documentation says it all:

"Returns a handle if successful, or NULL otherwise. To retrieve a specific error message, call GetLastError."

http://msdn.microsoft.com/en-us/library/aa384166(VS.85).aspx

Upvotes: 1

Related Questions