Results 1 to 3 of 3

Thread: upload file in qml

  1. #1
    Join Date
    Oct 2015
    Posts
    46
    Thanks
    19
    Platforms
    Windows

    Default upload file in qml

    i want to send file to server.
    it is a sample in the javascript:
    Qt Code:
    1. <!DOCTYPE html>
    2. <html>
    3. <head>
    4. <script>
    5. function tabe(){
    6. var file = document.getElementById('files').files[0];
    7. var fd = new FormData;
    8. fd.append('photo',file);
    9. var xhr = new XMLHttpRequest();
    10. xhr.addEventListener('load', function(){
    11. alert(this.responseText);
    12. });
    13. xhr.open('post', 'get.php', true);
    14. xhr.send(fd);
    15. }
    16. </script>
    17. </head>
    18. <body>
    19. <form action="get.php" enctype="multipart/form-data" method="post">
    20. <input id="files" name="photo" type="file">
    21. <input type="button" value="آپلود فایل" onclick="tabe();">
    22. </form>
    23. </body>
    24. </html>
    To copy to clipboard, switch view to plain text mode 
    i want to do that in the qml.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: upload file in qml

    do YOU want to do it in QML or do you want US to do it for you?
    What is your actual question?
    I assume you know you can embed JS in QML, right?
    That sort of logic is however better of in the backend and not in QML.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3

    Default Re: upload file in qml

    Do you provide your own server? If you consider using Firebase Cloud Storage, you can find an QML example in this blog post: https://v-play.net/updates/release-2...-all-platforms

Similar Threads

  1. ftp file upload
    By mouni in forum Newbie
    Replies: 11
    Last Post: 8th September 2016, 16:01
  2. QFtp upload file to server
    By djo87 in forum Qt Programming
    Replies: 2
    Last Post: 30th May 2012, 02:55
  3. Replies: 1
    Last Post: 21st October 2010, 05:59
  4. Qhttp Upload file
    By danny.lesnik in forum Qt Programming
    Replies: 5
    Last Post: 11th December 2009, 10:02
  5. QNetworkRequest file upload -- please help
    By Runtime Technologies in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2009, 16:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.