The process of sadness I will not say, direct serving.
How to use QT implementation: curl-f [email protected] Http://www.fatjb.com/uploadfile
Qfile file (M_staskplistpath), if (File.exists ()) { if (!file.open (QIODevice::ReadOnly)) ) { qmessagebox::warning (This, tr (" Warning "), tr (" Open task.plist failed! "), qmessagebox::yes); return; } qbytearray filecontent = file.readall (); File.close (); qstring scrlf= "\ r \ n"; qsrand (Qdatetime::currentdatetime (). totime_t ()); qstring b=qvariant (Qrand ()) . ToString () +qvariant (Qrand ()). ToString () +qvariant (Qrand ()). ToString (); qstring sboundary= "---------------------------" +b; qstring sendboundary=scrlf+ "--" + sboundary+ "--" +scrlf; qstring scontenttype= "multipart/form-data; boundary=" +sboundary; sboundary= "--" +sboundary+scrlf; qbytearray Boundary=sboundary.toascii (); qbytearray senddata; senddata.append (boundary); sboundary = scrlf + Sboundary; boundary = sboundary.toascii (); Senddata.append (QString ("content-disposition: form-data; name=\" file\ "; filename=\" "+QString (m_ Staskplistpath.toutf8 (). Constdata ()) + "\" "+scrlf). Toascii ()); senddata.append (QString (" Content-transfer-encoding: 8bit "+scrlf). Toascii ()); senddata.append (SCrlf.toAscii ( ); senddata.append (filecontent); senddata.append ( Sendboundary.toascii ()); qnetworkrequest req (QUrl (m_ Saddress+m_suploadpath)); req. SetHeader (Qnetworkrequest::contenttypeheader, scontenttype.toascii ()); Req.setheader (Qnetworkrequest::contentlengthheader, qvariant (Senddata.size ()). ToString ()); qnetworkreply* preply = m_pmanager->post (Req, senddata); connect (preply, signal (Error (Qnetworkreply::networkerror)), slot (networkerror:: Networkerror)));} Else{ qmessagebox::warning (THIS, TR ("Warning"), tr ("Task.plist does not exist! "), qmessagebox::yes);}
Why would I know? Next Wireshark grab the bag, then follow the correct package slowly tune to know, sure enough or not lazy.
Qnetworkaccessmanager Implement Curl Upload form file