PDA

View Full Version : upload file in qml



ravandi
25th March 2017, 10:47
i want to send file to server.
it is a sample in the javascript:

<!DOCTYPE html>
<html>
<head>
<script>
function tabe(){
var file = document.getElementById('files').files[0];
var fd = new FormData;
fd.append('photo',file);
var xhr = new XMLHttpRequest();
xhr.addEventListener('load', function(){
alert(this.responseText);
});
xhr.open('post', 'get.php', true);
xhr.send(fd);
}
</script>
</head>
<body>
<form action="get.php" enctype="multipart/form-data" method="post">
<input id="files" name="photo" type="file">
<input type="button" value="آپلود فایل" onclick="tabe();">
</form>
</body>
</html>
i want to do that in the qml.

high_flyer
29th March 2017, 15:17
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.

alex.huber
13th June 2018, 14:04
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-17-0-firebase-cloud-storage-downloadable-resources-at-runtime-and-native-file-access-on-all-platforms