Results 1 to 3 of 3

Thread: uploading files to HTTP!!

  1. #1
    Join Date
    May 2008
    Posts
    12
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default uploading files to HTTP!!

    Hi all,

    I have written a small app to connect to a HTTP server and transffer files via HTTP post. It
    actually should upload jpeg files to http set-up.

    here is the code I have written,

    Qt Code:
    1. void Sender( QString postfile , QString posturl)
    2. {
    3. QUrl url(posturl);
    4. http->setHost(url.host(), 80);
    5. QFile *putFile = new QFile(postfile);
    6. putFile->open(QIODevice::ReadOnly);
    7. int filesize = putFile->size();
    8. QHttpRequestHeader header("POST", url.path()); /* header */
    9. header.setValue("enctype","multipart/form-data");
    10. header.setValue("Host", url.host());
    11. header.setValue("Content-type","image/jpeg");
    12. header.setValue("Connection", "keep-alive");
    13. header.setValue("Size",QString::number(filesize));
    14. header.setContentType("image/jpeg");
    15. header.setContentLength(filesize);
    16. http->request(header, putFile);
    17. }
    To copy to clipboard, switch view to plain text mode 
    Iam filling in all the data to the request header and sending it to http request. But I am getting error 5: Internal server error. Am I doing some thing wrong here?

    Thanks,
    Raajesh
    Last edited by jpn; 28th June 2008 at 22:24. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2008
    Location
    Brasil
    Posts
    131
    Thanks
    18
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb Re: uploading files to HTTP!!

    Hi,

    I believe you will have a better experience developing what you want, using ftp. So you will have more possibilities.

    Marcelo Geyer
    Brazil.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: uploading files to HTTP!!

    Quote Originally Posted by Raajesh View Post
    header.setValue("enctype","multipart/form-data");
    Are you sure this is correct and matches the way you send data?

Similar Threads

  1. visual studio project files - adding extra files
    By luf in forum Qt Programming
    Replies: 3
    Last Post: 13th June 2008, 22:05
  2. Replies: 5
    Last Post: 22nd September 2006, 09:04
  3. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 11:28

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.