Home > Software engineering >  Windows upload FTP file coding issues
Windows upload FTP file coding issues

Time:09-20

Use Windows library FTP uploading files, is always difficult to understand the coding problem,

Is called FtpPutFile (), file name is turned utf-8, but the upload result is very strange,

If the file name with Chinese characters, if is an odd number, the last of the Chinese character is a garbled, if it was even position, is very normal,
But sometimes meet individual Chinese characters "ni", even if the coded also have a question,


Such as a local file called "13361 - ni f. Wav", upload go up and then become, such as "13361 - NiYao?? Wav,
"
Use wireshark capture the package and found that the problem was out on the client side,

Is converted into a "STOR... "This step is out of the question, obviously lost part of coding,



FtpPutFile (m_hInetConn pszFilePath, transFile FTP_TRANSFER_TYPE_BINARY, NULL)


Later tried directly use Windows explorer to upload files, also is the same effect, is there a bug?

CodePudding user response:

First FtpCommand "FEAT" see if the server supports utf-8
So, sending OPTS UTF8 ON some servers for this command will return 501 do CLNT first denial of service, for starters CLNT instructions

Server does not support utf-8 filename (such as IIS 7), with my luck gb2312,

CodePudding user response:

Try to use UNICODE version FtpPutFileW

CodePudding user response:

Urlencode?
  • Related