void ServerApiFacade::ftpPut(const QString &localFileName, const QString &serverFileName){ m_ftpFile = new QFile(localFileName); if (m_ftpFile->open(QIODevice::ReadWrite)) { QUrl url; url.setScheme("ftp"); url.setHost(m_ftpServer); url.setPath(serverFileName); // Если в имени русские символы, то выдаётся ошибка url.setPassword(m_ftpPassword); url.setUserName(m_ftpLogin); url.setPort(m_ftpPort); QNetworkAccessManager *manager = new QNetworkAccessManager(); connect(manager, &QNetworkAccessManager::finished, this, &ServerApiFacade::finishFtp); QNetworkRequest networkRequest; networkRequest.setUrl(url); manager->put(networkRequest, m_ftpFile); return; } QString ftpErrorString = tr("File '%1' doesn't open."); ftpErrorString = ftpErrorString.arg(localFileName); emit ftpTransmissionError(ftpErrorString);}
C++ (Qt)serverFileName = QString::fromUtf8( "Русский текст в кодировке utf-8" ); // так, если исходный файл в кодировке utf-8serverFileName = QString( "Русский текст в кодировке utf-8" ); // а не так
QApplication::setOverrideCursor(Qt::WaitCursor); QString localFileName = QFileDialog::getOpenFileName(0, QObject::tr("Export data to Excel"), QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation), QObject::tr("Excel-Files (*.xlsx)")); QString serverFileName = localFileName; QFileInfo fileInfo(serverFileName); serverFileName = fileInfo.fileName();
serverFileName = "Кемерю 12 44.xlsx"; QMessageBox msgBox; msgBox.setText(serverFileName); msgBox.exec(); m_file = new QFile(localFileName); if (m_file->open(QIODevice::ReadWrite)) { QUrl url; url.setScheme("ftp"); url.setHost("rrr.rrtg-rk.ru"); url.setPath(serverFileName, QUrl::ParsingMode::TolerantMode); url.setPassword("ge34"); url.setUserName("pro213"); url.setPort(21); QNetworkRequest networkRequest; networkRequest.setUrl(url);