{
tr("Unable to open the file %1: %2.")
.arg(userfile->errorString()));
}
header.setValue("Host","192.168.100.161");
header.setValue("Content-type", "multipart/form-data, boundary=AaB03x");
header.setValue("Cache-Control", "no-cache");
header.setValue("Accept","*/*");
bytes.append("--AaB03x\r\n");
bytes.append("content-disposition: ");
bytes.append("form-data; name=\"uploadfile\"\r\n");
bytes.append("\r\n");
bytes.append("0\r\n");
bytes.append("--AaB03x\r\n");
bytes.append("content-disposition: ");
bytes.append("form-data; name=\"uploadfile\"; filename=\"" + byt+ "\"\r\n");
bytes.append("Content-Transfer-Encoding: binary\r\n");
bytes.append("\r\n");
bytes.append(userfile->readAll());
userfile->close(); // the file is opened earlier in the code
bytes.append("\r\n");
bytes.append("--AaB03x--");
int contentLength = bytes.length();
header.setContentLength(contentLength);
http->request(header, bytes,0);
QString fileName = filename;
QFile *userfile = new QFile(fileName);
if ( !userfile->open(QIODevice::ReadOnly) )
{
QMessageBox::information(this, tr("HTTP"),
tr("Unable to open the file %1: %2.")
.arg(userfile->errorString()));
}
QHttpRequestHeader header("POST", "/macUpd.php",1,1);
header.setValue("Host","192.168.100.161");
header.setValue("Content-type", "multipart/form-data, boundary=AaB03x");
header.setValue("Cache-Control", "no-cache");
header.setValue("Accept","*/*");
QByteArray byt(fileName.toUtf8());
QByteArray bytes;
bytes.append("--AaB03x\r\n");
bytes.append("content-disposition: ");
bytes.append("form-data; name=\"uploadfile\"\r\n");
bytes.append("\r\n");
bytes.append("0\r\n");
bytes.append("--AaB03x\r\n");
bytes.append("content-disposition: ");
bytes.append("form-data; name=\"uploadfile\"; filename=\"" + byt+ "\"\r\n");
bytes.append("Content-Transfer-Encoding: binary\r\n");
bytes.append("\r\n");
bytes.append(userfile->readAll());
userfile->close(); // the file is opened earlier in the code
bytes.append("\r\n");
bytes.append("--AaB03x--");
int contentLength = bytes.length();
header.setContentLength(contentLength);
http->request(header, bytes,0);
To copy to clipboard, switch view to plain text mode
Bookmarks