Results 1 to 5 of 5

Thread: errors while upload files on http server????

  1. #1
    Join Date
    Feb 2011
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question errors while upload files on http server????

    Hi,

    I tried below given code for uploading files on http server which was posted on the forum.But it is giving some errors.plz help me to remove them out.
    Iam not able to understand what the error is..plz help me urgently.

    Qt Code:
    1. #include "http.h"
    2. void HttpGet :: postfile()
    3. {
    4. int i = 0;
    5.  
    6. QString filename;
    7.  
    8. QString files = QFileDialog::getOpenFileName(this, tr("Select File"),"D://");
    9.  
    10. if (files.isEmpty())
    11.  
    12. return;
    13.  
    14. file = new QFile(filename);
    15.  
    16. Q_ASSERT(file != NULL);
    17. if(!file->open(QIODevice::ReadWrite))
    18.  
    19. {
    20.  
    21. qDebug() << "opern err" << file->fileName();
    22.  
    23. return;
    24.  
    25. }
    26.  
    27. qDebug() << "Upload strat";
    28. http->put(file,filename);
    29. qDebug() << "Upload end";
    30. }
    To copy to clipboard, switch view to plain text mode 

    The errors after running program are.

    1)error: no matching function for call to ‘QFileDialog::getOpenFileName(HttpGet* const, QString, const char [5])’
    2)14: error: no match for ‘operator=’ in ‘((HttpGet*)this)->HttpGet::file = (operator new(8u), (<statement>, ((QFile*)<anonymous>)))’
    3)16: error: no match for ‘operator!=’ in ‘((HttpGet*)this)->HttpGet::file != 0’

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: errors while upload files on http server????

    The answers of error are:

    1) HttpGet is not inherited from QWidget;

    2) You MUST inckude <QFile>

    3) file is a memmer of HttpGet and isn't a QFile*;

    Post your Header
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Feb 2011
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Re: errors while upload files on http server????

    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---------------
    Qt Code:
    1. #include "http.h"
    2. #include <QFileDialog>
    3. #include <QMessageBox>
    4. #include <QProgressDialog>
    5. #include <iostream>
    6. #include <QDebug>
    7. using namespace std;
    8.  
    9. http::http(QWidget *parent)
    10. : QMainWindow(parent)
    11. {
    12. }
    13.  
    14. http::~http()
    15. {
    16.  
    17. }
    18.  
    19. HttpGet::HttpGet(QObject *parent)
    20. : QObject(parent)
    21. {
    22. connect(&http, SIGNAL(done(bool)), this, SLOT(HttpDone(bool)));
    23. }
    24.  
    25. void HttpGet::putFile()
    26. {
    27. QString filename;
    28. QString files = QFileDialog::getOpenFileName(0, tr("Select File"),"/home/supriya/supri.c");
    29. if (files.isEmpty())
    30. return;
    31. QFile *file = new QFile(filename);
    32. Q_ASSERT(file != NULL);
    33. if(!file->open(QIODevice::ReadWrite))
    34. {
    35. qDebug() << "opern err" << file->fileName();
    36. return;
    37. }
    38. qDebug() << "Upload start";
    39. http.put(file,filename);
    40. qDebug() << "Upload end";
    41. }
    To copy to clipboard, switch view to plain text mode 
    ------------this is header file------------
    Qt Code:
    1. #ifndef HTTP_H
    2. #define HTTP_H
    3.  
    4. #include <QtGui/QMainWindow>
    5. #include <QUrl>
    6. #include <QHttp>
    7. #include <QFile>
    8. #include <iostream>
    9. #include <QFileInfo>
    10.  
    11. using namespace std;
    12. class http : public QMainWindow
    13. {
    14. Q_OBJECT
    15.  
    16. public:
    17. http(QWidget *parent = 0);
    18. ~http();
    19. };
    20.  
    21. class HttpGet : public QObject
    22. {
    23. Q_OBJECT
    24.  
    25. public:
    26. HttpGet(QObject *parent = 0);
    27. bool getFile(const QUrl &url);
    28. void putFile();
    29. signals:
    30. void done();
    31.  
    32. private slots:
    33. void HttpDone(bool error);
    34.  
    35.  
    36. private:
    37. QHttp http;
    38. QFile file;
    39. };
    40.  
    41. #endif // HTTP_H
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: errors while upload files on http server????

    I think you're little bit confused

    1) i am nt getting what method should i use for uploading the file??
    You are speaking about upload a file on vsftpd server, then you have to use FTP protocol.
    See QFtp class. It has the QFtp::put method that allows to send file to a FTP server.

    2)am using vsftpd server. can u tel me where is the uploaded data stored on this server????
    it depends from vsftpd server configuration.
    A camel can go 14 days without drink,
    I can't!!!

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,589
    Thanks
    13
    Thanked 1,585 Times in 1,514 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: errors while upload files on http server????

    Quote Originally Posted by sups View Post
    The errors after running program are.

    1)error: no matching function for call to ‘QFileDialog::getOpenFileName(HttpGet* const, QString, const char [5])’
    2)14: error: no match for ‘operator=’ in ‘((HttpGet*)this)->HttpGet::file = (operator new(8u), (<statement>, ((QFile*)<anonymous>)))’
    3)16: error: no match for ‘operator!=’ in ‘((HttpGet*)this)->HttpGet::file != 0’
    These are compilation errors, and nothing to do with running your program. When faced with these sorts of errors you should:
    1. Start at the first error message
    2. Read the error message
    3. Read the error message again. Really. The compiler is telling you something useful even if you can't see it the first time.
    4. Read the documentation for the classes and methods you are trying to use
    5. Have an Aha! moment and fix the problem
    6. Move on to any remaining errors after trying to compile again


    Only when it compiles will you be able to address the errors in the logic of your running program.

Similar Threads

  1. SSL errors on QT HTTP example application
    By manekineko in forum Qt Programming
    Replies: 4
    Last Post: 18th February 2011, 14:50
  2. How to upload file to HTTP server (POST Method)
    By Alex Snet in forum Qt Programming
    Replies: 8
    Last Post: 24th January 2011, 23:49
  3. QFtp:upload file to server
    By ensky_cy in forum Qt Programming
    Replies: 6
    Last Post: 14th December 2009, 11:42
  4. upload files using QNetworkAccessManager
    By Raajesh in forum Qt Programming
    Replies: 1
    Last Post: 30th June 2008, 20:43
  5. server upload
    By ag.sitesh in forum Qt Programming
    Replies: 1
    Last Post: 1st April 2008, 14:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.