在專案中需要將本地的乙個資料夾上傳到伺服器,於是想到先將起壓縮成zip檔案,然後上傳。壓縮功能的做法見另一篇博文qt將資料夾壓縮成zip檔案.
由於經驗所限,不太懂網路程式設計。根據例子,使用 qnetworkaccessmanager 和 qnetworkrequest 上傳檔案內容,總是錯誤。最後在一些好友的幫助下,終於解決了問題,記下來備忘。也希望給遇到類似問題的同學乙個幫助。由於沒有弄懂真正的原理和機制,僅貼出**,給有需要的同學參考。
把**也粘上:
void uploadfile_api::sendrequest(const qstring &username, const qstring &teachersession, const qstring &zipfile)
//設定傳送的資料
//設定頭資訊
//傳送請求
qnetworkreply *networkreply = m_networkmanager->post(networkrequest, multipart);
multipart->setparent(networkreply); // delete the multipart with the reply
}
qt壓縮檔案
qt版本 qt opensource windows x86 mingw491 opengl 5.4.1.exe 2 向quazip中的quazip專案的.pri檔案中新增qt中zlib庫的路徑 includepath d qt5.4.1 5.4 mingw491 32 include qtzlib...
Qt之使用quazip來壓縮檔案
我使用的是qt5.7版本,好像5.12版本將quazip已經整合到安裝包中。不管5.12版本,以下是5.7版本整合quazip的方法,使用的編譯工具為qt creator.提取碼 hkev csdn cmakelists.txt copying doxyfile findquazip.cmake i...
Python 使用Python壓縮檔案 資料夾
def zip ya startdir,file news import zipfile z zipfile.zipfile file news,w zipfile.zip deflated 引數一 資料夾名 for dirpath,dirnames,filenames in os.walk sta...