void nomkl_num::getfiles(){ int i = 0; QStringList st; QString str,file_str; str = http_sp->readAll(); st = str.split("\n"); while (i != st.count()) { file_str = st.value(i); if (file_str != "..") { if (file_str != ".") { if (file_str != "") { sp.append(file_str); } } } i++; } i = 0; while(i != sp.count()) { QHttpRequestHeader header("GET", "/farma/zagruz/"+sp.value(i)); header.setValue("Host", "192.168.1.223"); header.setValue("Content-type", "multipart/form-data; boundary=1BEF0A57BE110FD467A\r\n"); header.setValue( "User-Agent", "User Agent"); header.setContentType("application/x-www-form-urlencoded"); http_save = new QHttp(this); connect(http_save, SIGNAL(done(bool)), this, SLOT(savefiles())); http_save->setHost("192.168.1.223"); http_save->request(header); i++; }}void nomkl_num::savefiles(){ QDir dir; bool ok; QFile file("files/"+sp.value(zakaz)); zakaz++; file.open(QIODevice::WriteOnly); file.write(http_save->readAll().trimmed()); file.close(); }
C++ (Qt)void nomkl_num::savefiles(){ QDir dir; bool ok; QFile file("files/"+sp.value(zakaz)); zakaz++; file.open(QIODevice::WriteOnly); file.write(http_save->readAll().trimmed()); file.close(); }
QHttpRequestHeader header("GET", "/farma/spisok_files.php"); header.setValue("Host", "192.168.1.223"); header.setValue("Content-type", "multipart/form-data; boundary=1BEF0A57BE110FD467A\r\n"); header.setValue( "User-Agent", "User Agent"); header.setContentType("application/x-www-form-urlencoded"); http_sp = new QHttp(this); connect(http_sp, SIGNAL(done(bool)), this, SLOT(getfiles())); http_sp->setHost("192.168.1.223"); http_sp->request(header);
int i = 0; QStringList st; QString str,file_str; str = http_sp->readAll(); st = str.split("\n"); while (i != st.count()) { file_str = st.value(i); if (file_str != "..") { if (file_str != ".") { if (file_str != "") { sp.append(file_str); } } } i++; } i = 0;while(i != sp.count()) { QHttpRequestHeader header("GET", "/farma/zagruz/"+sp.value(i)); header.setValue("Host", "192.168.1.223"); header.setValue("Content-type", "multipart/form-data; boundary=1BEF0A57BE110FD467A\r\n"); header.setValue( "User-Agent", "User Agent"); header.setContentType("application/x-www-form-urlencoded"); http_save = new QHttp(this); connect(http_save, SIGNAL(done(bool)), this, SLOT(savefiles())); http_save->setHost("192.168.1.223"); http_save->request(header); }
C++ (Qt)http_save = new QHttp(this);
C++ (Qt)file.write(http_save->readAll().trimmed());
C++ (Qt)void nomkl_num::savefiles(bool err){ if(err) { qDebug("Error occured"); return; } QHttp *http = qobject_cast<QHttp *>(sender()); if(!http) { qDebug("Cannot cast to QHttp"); return; } // если zakaz == 1, это не означает что скачался файл sp.value(1) QFile file("files/"+sp.value(zakaz)); zakaz++; if(!file.open(QIODevice::WriteOnly)) { qDebug("Cannot open file for writing"); return; } file.write(http->readAll().trimmed()); file.close(); }
void nomkl_num::on_get_files_triggered(){ QHttpRequestHeader header("GET", "/farma/spisok_files.php"); header.setValue("Host", "192.168.1.223"); header.setValue("Content-type", "multipart/form-data; boundary=1BEF0A57BE110FD467A\r\n"); header.setValue( "User-Agent", "User Agent"); header.setContentType("application/x-www-form-urlencoded"); http_sp = new QHttp(this); connect(http_sp, SIGNAL(done(bool)), this, SLOT(getfiles())); http_sp->setHost("192.168.1.223"); http_sp->request(header);}
void nomkl_num::getfiles(){ int i = 0; QStringList st; QString str,file_str; str = http_sp->readAll(); st = str.split("\n"); while (i != st.count()) { file_str = st.value(i); if (file_str != "..") { if (file_str != ".") { if (file_str != "") { sp.append(file_str); } } } i++; } i = 0; while (i != sp.count()) { QHttpRequestHeader header_s("GET", "farma/"+sp.value(i)); header_s.setValue("Host", "192.168.1.223"); header_s.setValue("Content-type", "multipart/form-data; boundary=1BEF0A57BE110FD467A\r\n"); header_s.setValue( "User-Agent", "User Agent"); header_s.setContentType("application/x-www-form-urlencoded"); http = new QHttp(this); http->setHost("192.168.1.223"); connect(http, SIGNAL(done(bool)), this, SLOT(savefiles(bool))); http->request(header_s); i++; }}
void nomkl_num::savefiles(bool err){ if(err) { qDebug() << "Error occured"; return; } QHttp *http = qobject_cast<QHttp *>(sender()); if(!http) { qDebug() << "Cannot cast to QHttp"; return; } // если zakaz == 1, это не означает что скачался файл sp.value(1) QFile file("files/"+sp.value(zakaz)); zakaz++; if(!file.open(QIODevice::WriteOnly)) { qDebug() << "Cannot open file for writing"; return; } file.write(http->readAll().trimmed()); file.close();}
QHttpRequestHeader header("GET", "farma/zagruzup00000000001.dlb"); header.setValue("Host", "192.168.1.223"); header.setValue("Content-type", "multipart/form-data; boundary=1BEF0A57BE110FD467A\r\n"); header.setValue( "User-Agent", "User Agent"); header.setContentType("application/x-www-form-urlencoded"); http = new QHttp(this); connect(http, SIGNAL(done(bool)), this, SLOT(savefiles(bool))); http->setHost("192.168.1.223"); http->request(header);
void nomkl_num::on_get_files_triggered()//нажатие кнопки в меню - загрузить{ QNetworkRequest request; // Формируем запрос request.setUrl(QUrl("192.168.1.223/farma/zotchet.php")); QNetworkAccessManager manager; manager.moveToThread(QApplication::instance()->thread()); reply = manager.get(request); //Отправляем запрос reply->moveToThread(QApplication::instance()->thread()); connect(&manager, SIGNAL(finished(QNetworkReply*)),this, SLOT(replyFinished(QNetworkReply*))); connect(reply,SIGNAL(readyRead()),this,SLOT(readyRead()));}//------------------------------------------------------------------------------------------------------------------------------------------------------void nomkl_num::readyRead(){ file.setFileName("files/123.txt"); file.open(QIODevice::WriteOnly); qDebug() << reply->readAll(); file.write(reply->readAll());}void nomkl_num::replyFinished(QNetworkReply *){ if (reply->error()) { qDebug() << "error download" << reply->errorString(); QCoreApplication::quit(); }else { qDebug() << "download complete"; file.close(); QCoreApplication::quit(); }}