File download - How to open the file?
Unsolved
General and Desktop
-
Hi,
I am trying to download the file from the server through QML. I created an file called abc.tpk and map the path for file response.But I am getting an error stating:
additionalMessage: The file path to the response file could not be opened.
Query: Do we need to pen the file through QML like file.open in CPP. If it is the case, how to open the file in QML.
QString filenamep = "Prefecture.tpk"; QFile file(filenamep); file.open(QIODevice::WriteOnly); if(!file.open(QIODevice::WriteOnly)) { } QString strUrl="http://testser/home/item.html?id=83d1c9aaf9d04e60bda3e822f25a8c67"; QUrl url = QUrl::fromUserInput(strUrl); QFileInfo fileInfo(url.path()); // QString strhost = url.encodedHost(); QString filename = fileInfo.fileName(); file.setFileName("C:\\Qt\\QHttp\\"+filename); http.setHost(url.host(),url.port(80)); http.get(url.path(),&file); file.write(http.readAll()); http.close(); file.close();