Qt Uploading music to website [SOLVED]
-
wrote on 11 Jun 2014, 12:48 last edited by
Hello,
I am working on an audio application which creates audio files. I would like to give the user the possibility to upload this file on my website www.mysite.com.
Is it possible to achieve this?
What would be the way to go?
Cheers -
Sure it's possible.
You can use QNetworkAccessManager "post":http://qt-project.org/doc/qt-5/qnetworkaccessmanager.html#post-2 method to connect to your website and upload a file.
Of course you'll need to provide some authorization mechanism and a service that can receive files on the server side. -
wrote on 11 Jun 2014, 13:10 last edited by
Thank you for your help. Could you please give some tips for the second part of your answer? (even if it over extends qt field)
How would you do that? -
It greatly depends on the technology you use for the server: PHP, Java, Ruby, node.js etc. and the type of protocols you choose: REST, SOAP, XML-rpc etc.
Then there's server itself - apache, iis, tomcat etc.There's like a gazillion possible answers to that question.
Just google "<your technology> file upload example" and there will be many answers to choose from. -
wrote on 11 Jun 2014, 13:38 last edited by
Chris, the only constraint I have is to use wordpress for the website ;)
-
Well then, as I said: "wordpress file upload example" ;)
As I recall servers hosting wordpress usually support FTP access, so it could be something like
@
QUrl url("ftp://mysizte/files/some_file.mp3");
url.setUserName("user");
url.setPassword("password");
url.setPort(21);QFile src("some_file.mp3");
if (src->open(QIODevice::ReadOnly)) {
QNetworkReply reply = qnam->put(QNetworkRequest(url), src);
...
@
This is off the top of my head so some tweaks will surely be needed.
Of course you can monitor progress and get notified about finish or errors via various reply signals. Read the docs of QNetworkReply and QNetworkAccessManager. -
wrote on 11 Jun 2014, 14:01 last edited by
Thank you very much. Mark as solved !
Cheers
6/7