i tried as per ur reply.but there is an error
error: ‘class QHttp’ has no member named ‘put’
i used post() method instead of put bt it gives error
error: no matching function for call to ‘QHttp:ost(QFile*&, QString&)’
1) i am nt getting what method should i use for uploading the file??
2)am using vsftpd server. can u tel me where is the uploaded data stored on this server????
3)is it necessary to use seperate http server for this??
plz reply urgently.
below is the code for http uploading files:
------------http_put.cpp---------------
#include "http.h"
#include <QFileDialog>
#include <QMessageBox>
#include <QProgressDialog>
#include <iostream>
#include <QDebug>
using namespace std;
{
}
http::~http()
{
}
{
connect(&http, SIGNAL(done(bool)), this, SLOT(HttpDone(bool)));
}
void HttpGet::putFile()
{
QString files
= QFileDialog::getOpenFileName(0, tr
("Select File"),
"/home/supriya/supri.c");
if (files.isEmpty())
return;
Q_ASSERT(file != NULL);
{
qDebug() << "opern err" << file->fileName();
return;
}
qDebug() << "Upload start";
http.put(file,filename);
qDebug() << "Upload end";
}
#include "http.h"
#include <QFileDialog>
#include <QMessageBox>
#include <QProgressDialog>
#include <iostream>
#include <QDebug>
using namespace std;
http::http(QWidget *parent)
: QMainWindow(parent)
{
}
http::~http()
{
}
HttpGet::HttpGet(QObject *parent)
: QObject(parent)
{
connect(&http, SIGNAL(done(bool)), this, SLOT(HttpDone(bool)));
}
void HttpGet::putFile()
{
QString filename;
QString files = QFileDialog::getOpenFileName(0, tr("Select File"),"/home/supriya/supri.c");
if (files.isEmpty())
return;
QFile *file = new QFile(filename);
Q_ASSERT(file != NULL);
if(!file->open(QIODevice::ReadWrite))
{
qDebug() << "opern err" << file->fileName();
return;
}
qDebug() << "Upload start";
http.put(file,filename);
qDebug() << "Upload end";
}
To copy to clipboard, switch view to plain text mode
------------this is header file------------
#ifndef HTTP_H
#define HTTP_H
#include <QtGui/QMainWindow>
#include <QUrl>
#include <QHttp>
#include <QFile>
#include <iostream>
#include <QFileInfo>
using namespace std;
{
Q_OBJECT
public:
~http();
};
{
Q_OBJECT
public:
bool getFile
(const QUrl &url
);
void putFile();
signals:
void done();
private slots:
void HttpDone(bool error);
private:
};
#endif // HTTP_H
#ifndef HTTP_H
#define HTTP_H
#include <QtGui/QMainWindow>
#include <QUrl>
#include <QHttp>
#include <QFile>
#include <iostream>
#include <QFileInfo>
using namespace std;
class http : public QMainWindow
{
Q_OBJECT
public:
http(QWidget *parent = 0);
~http();
};
class HttpGet : public QObject
{
Q_OBJECT
public:
HttpGet(QObject *parent = 0);
bool getFile(const QUrl &url);
void putFile();
signals:
void done();
private slots:
void HttpDone(bool error);
private:
QHttp http;
QFile file;
};
#endif // HTTP_H
To copy to clipboard, switch view to plain text mode
Bookmarks