PDA

View Full Version : uploading files to HTTP!!



Raajesh
24th June 2008, 17:41
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,


void Sender( QString postfile , QString posturl)
{
QUrl url(posturl);
http->setHost(url.host(), 80);
QFile *putFile = new QFile(postfile);
putFile->open(QIODevice::ReadOnly);
int filesize = putFile->size();
QHttpRequestHeader header("POST", url.path()); /* header */
header.setValue("enctype","multipart/form-data");
header.setValue("Host", url.host());
header.setValue("Content-type","image/jpeg");
header.setValue("Connection", "keep-alive");
header.setValue("Size",QString::number(filesize));
header.setContentType("image/jpeg");
header.setContentLength(filesize);
http->request(header, putFile);
}

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

estanisgeyer
24th June 2008, 20:26
Hi,

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

Marcelo Geyer
Brazil.

jacek
24th June 2008, 23:00
header.setValue("enctype","multipart/form-data");
Are you sure this is correct and matches the way you send data?