QHttpMultiPart: post files to PHP script

我的梦境 提交于 2019-12-03 08:30:40
flatface

Solved!

Thanks to this question for the hint - I added 'filename' to the content disposition for the QHttpPart and it now uploads as expected. I thought filename was optional but seems to work in this case. Hope this helps someone else!

QString preview_name = "preview.jpg";

QHttpPart previewFilePart;
previewFilePart.setHeader(QNetworkRequest::ContentTypeHeader,    QVariant("image/jpeg"));
previewFilePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"preview_file\"; filename=\""+ preview_name + "\""));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!