Home > Mobile >  Qt5 Ftp upload binaries
Qt5 Ftp upload binaries

Time:11-05

I need through Qt5 to write a simple FTP client upload function, from the Windows 7 to embedded Linux, upload cross compiled executable binary file, the problem is: upload a success, but the file size has changed,
After upload, through the FIlezilla FTP download again to Windows 7, through compare the beyond compare, found a lot of 0 x0d more, I think may be in the process of transfer at the end of each line adds a newline (0 x0d),

Because QFtp Qt5 not in use, so I use QNetworkAccessManager, upload, developed the problem; QFtp then download the source code to compile the use of dynamic link library, upload, or the above questions,
Excuse me, does anyone know how to refuse this problem?
Thank you,

The following code is to use QNetworkAccessManager
 
AccessManager QNetworkAccessManager *=new QNetworkAccessManager (this);
AccessManager - & gt; SetNetworkAccessible (QNetworkAccessManager: : Accessible);

QUrl (" ftp://"url + + RemoteFileName m_devIp);
Url. SetUserName (" root ");
Url. The setPassword (" 123456 ");
Url. SetPort (21);

M_file=new QFile (LocalFileName);
If (m_file - & gt; Open (QIODevice: : ReadOnly)) {
QByteArray byteArray containing=m_file - & gt; ReadAll ();
M_reply=accessManager - & gt; Put (QNetworkRequest (url), byteArray containing);

}
The connect (accessManager, SIGNAL (finished (QNetworkReply *)),
This SLOT (ftpReplyFinished (QNetworkReply *)));
The connect (m_reply, SIGNAL (uploadProgress (qint64 qint64)),
This SLOT (ftp_loadProgress (qint64 qint64))); [/size]


The following use QFtp code
 m_ftp=new QFtp (); 
M_ftp - & gt; ConnectToHost (m_devIp, 21);
M_ftp - & gt; Login (" root ", runPara ftpPasswd);

M_file=new QFile (LocalFileName);
If (m_file - & gt; Open (QIODevice: : ReadOnly)) {
M_ftp - & gt; Put (m_file RemoteFileName, QFtp: : Binary);

The connect (m_ftp, SIGNAL (dataTransferProgress (qint64 qint64)),
This SLOT (ftp_loadProgress (qint64 qint64)));
The connect (m_ftp, SIGNAL (commandFinished (int, Boolean)),
This SLOT (qftp_CommandFinished (int, Boolean)));
}


File compare the following

One on the left is a normal file, on the right is the upload, and download files

CodePudding user response:

  •  Tags:  
  • Qt
  • Related