我试图将文件上传到FTP服务器,该服务器是由vsftpd创建的本地服务器。我已经设置了在vsftpd.conf文件中连接和传输文件所需的必要参数。我的要求是将文件上传到此服务器。当我记录statechanged消息时,HostLookup,Connecting,Connected,Logged,closing和Unconnected消息是由我的ftp对象发出的。但是,当我检查目标目录时,文件存在但是大小为0 ......什么可能是错误的?以下是我使用的代码...使用Qt在Linux上不成功上传到ftp服务器
QImage img("./Sample.jpg");
QBuffer* buf = new QBuffer();
buf->open(QBuffer::ReadWrite);
buf->seek(0);
img.save(buf, "jpg");
connection = new QFtp();
connection->connectToHost("localhost");
connection->login();
connection->cd("ftpshare/");
connection->put(buf, "Sample.jpg", QFtp::Binary);
qDebug(QString::number(connection->error()).toLatin1());
qDebug(connection->errorString().toLatin1());
connect(connection,SIGNAL(stateChanged(int)),this,SLOT(ftpstatechanged(int)));
connection->close();