Funklord
7th February 2006, 15:25
I am having trouble with QHttp and related classes when trying to post a file to a server.
No matter what I try, the header response is: "Internal server error"
My code below (error checks, signals and checks for return values removed for clarity)
QHttp *http;
QFile *file;
QUrl url(lineEdit_url->text());
file = new QFile(lineEdit_filename->text());
file->open(QIODevice::ReadOnly)
http->setHost(url.host(),url.port() != -1 ? url.port() : 80);
if(!url.userName().isEmpty())
http->setUser(url.userName(),url.password());
http->post(url.path(),file);
Here is a working html form for posting to this server:
<form method=post enctype="multipart/form-data" action=/uploader/Default.asp>
Username:<br/><input type="text" name="username"><br/><br/>
Password:<br/><input type="password" name="password"><br/><br/>
Your File:<BR><input type=file name=YourFile><BR><BR>
<input type=submit name=submit value="Upload">
</form>
There are no examples in qtassistant apart from the brief description of QHttp:: post() :mad:
Any help is deeply appreciated!
No matter what I try, the header response is: "Internal server error"
My code below (error checks, signals and checks for return values removed for clarity)
QHttp *http;
QFile *file;
QUrl url(lineEdit_url->text());
file = new QFile(lineEdit_filename->text());
file->open(QIODevice::ReadOnly)
http->setHost(url.host(),url.port() != -1 ? url.port() : 80);
if(!url.userName().isEmpty())
http->setUser(url.userName(),url.password());
http->post(url.path(),file);
Here is a working html form for posting to this server:
<form method=post enctype="multipart/form-data" action=/uploader/Default.asp>
Username:<br/><input type="text" name="username"><br/><br/>
Password:<br/><input type="password" name="password"><br/><br/>
Your File:<BR><input type=file name=YourFile><BR><BR>
<input type=submit name=submit value="Upload">
</form>
There are no examples in qtassistant apart from the brief description of QHttp:: post() :mad:
Any help is deeply appreciated!