<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic post image to website servr using javascript in Qt Maps SDK Questions</title>
    <link>https://community.esri.com/t5/qt-maps-sdk-questions/post-image-to-website-servr-using-javascript/m-p/1003908#M3839</link>
    <description>&lt;P&gt;kindly help to post image using httprequst&lt;/P&gt;</description>
    <pubDate>Mon, 23 Nov 2020 10:17:26 GMT</pubDate>
    <dc:creator>rsharma</dc:creator>
    <dc:date>2020-11-23T10:17:26Z</dc:date>
    <item>
      <title>post image to website servr using javascript</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/post-image-to-website-servr-using-javascript/m-p/1003908#M3839</link>
      <description>&lt;P&gt;kindly help to post image using httprequst&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 10:17:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/post-image-to-website-servr-using-javascript/m-p/1003908#M3839</guid>
      <dc:creator>rsharma</dc:creator>
      <dc:date>2020-11-23T10:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: post image to website servr using javascript</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/post-image-to-website-servr-using-javascript/m-p/1004681#M3844</link>
      <description>&lt;P&gt;Do you have any more details on the workflow? Are you using AppStudio?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 15:38:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/post-image-to-website-servr-using-javascript/m-p/1004681#M3844</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2020-11-25T15:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: post image to website servr using javascript</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/post-image-to-website-servr-using-javascript/m-p/1004943#M3847</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/184785"&gt;@LucasDanzinger&lt;/a&gt;&amp;nbsp;Yes, i am using arcgis appstudio. i am capturing photos from camera and storing it on mobile local db, after that i want to send it to my website server to be reusable on website.&lt;/P&gt;&lt;P&gt;i am able to store it in my mobile localdb, but could not post it on my website server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 12:21:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/post-image-to-website-servr-using-javascript/m-p/1004943#M3847</guid>
      <dc:creator>rsharma</dc:creator>
      <dc:date>2020-11-27T12:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: post image to website servr using javascript</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/post-image-to-website-servr-using-javascript/m-p/1005117#M3849</link>
      <description>&lt;P&gt;hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/184785"&gt;@LucasDanzinger&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;i am now trying like convert an image to buffer then to base64 and then sending it through xmlhttp request, but at server endpoint, the image could not be retrived due to invalid bse64 value.&lt;/P&gt;&lt;P&gt;Code is below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;import QtQuick 2.13
import QtQuick.Layouts 1.13
import QtQuick.Controls 2.13
import ArcGIS.AppFramework 1.0
import Esri.ArcGISRuntime 100.6
import QtQuick.Dialogs 1.0
import Qt.labs.settings 1.0
import QtQuick.Controls.Material 2.1
import "../../controls" as Controls
import "../../assets/js/backend.js" as Backend
App {
    id: appdem
    width: 400
    height: 640

    ColumnLayout {
        anchors {
            fill: parent
            margins: 10
        }
        ImageObject {
            id: imageObject

            onUrlChanged: {
                console.log("url:", url);
            }

            onImageChanged: {
                var buffer_data = imageObject.toArrayBuffer();
                Backend.demo(buffer_data);
            }
        }
        Button {
            text: "Load"
            onClicked: {
                console.log("API Key::"+settings.api_key);
                var img_path = "Modern-Office-3-Skype-Backgrounds.jpeg";
                imageObject.load(img_path);
            }
        }
        Image {
            fillMode: Image.PreserveAspectFit
            source: imageObject.url
            horizontalAlignment: Image.AlignHCenter
            verticalAlignment: Image.AlignVCenter
            cache: false
        } }}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;Then the demo fnc js file as below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;function arrayBufferToBase64( buffer ) {
    var binary = '';
    var bytes = new Uint8Array( buffer );
    var len = bytes.byteLength;
    for (var i = 0; i &amp;lt; len; i++) {
        binary += String.fromCharCode( bytes[ i ] );
    }
    return Qt.btoa( binary );
}
function demo(img_binary){
    var endpoint = 'insertDamageReport';
    //var img_data = new Uint8Array(img_binary);
   var base64String = arrayBufferToBase64( img_binary );
    console.log(base64String);
    //create HTTP REQUEST Object
   var xmlhttp = new XMLHttpRequest();
    //Opend request
    xmlhttp.open('POST', "https://abc.com"+endpoint, false);
    ///Set header data
    xmlhttp.setRequestHeader("Content-Type","application/json");
    //xmlhttp.setRequestHeader( 'Content-Type', 'multipart/form-data' );
    xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
    xmlhttp.setRequestHeader("AuthenticationInfo",JSON.stringify({"_key":"","_secret":"","device_id":"","access_token":""}) );
    //Set request to server
    var data = {"user_id":60,"booking_id":1,"report_content":"test","images":base64String};
    let params = (typeof data != 'undefined')?JSON.stringify(data):''
    xmlhttp.send(params);
    ///Handle Response
    if (xmlhttp.readyState === 4 &amp;amp;&amp;amp; xmlhttp.status === 200) {
        console.log(xmlhttp.responseText)
        //return JSON.parse(xmlhttp.responseText);
    }else if(xmlhttp.readyState === 4){
        console.log(xmlhttp.responseText);
        //return JSON.parse(xmlhttp.responseText);
    }}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;now the problem is it could not decode the code generated of base 64 not even on online base64 to image converter tool and on my server side php files&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 12:22:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/post-image-to-website-servr-using-javascript/m-p/1005117#M3849</guid>
      <dc:creator>rsharma</dc:creator>
      <dc:date>2020-11-27T12:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: post image to website servr using javascript</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/post-image-to-website-servr-using-javascript/m-p/1005530#M3854</link>
      <description>&lt;P&gt;From what I understand of your workflow, the ArcGIS Runtime recommended pattern would be to use Feature attachments and Feature Services - these support adding image files alongside a database record, but they require you to publish a feature service in ArcGIS Online or ArcGIS Enterprise. Here is a sample that demonstrates this - &lt;A href="https://github.com/Esri/arcgis-runtime-samples-qt/tree/master/ArcGISRuntimeSDKQt_QMLSamples/EditData/EditFeatureAttachments" target="_blank"&gt;https://github.com/Esri/arcgis-runtime-samples-qt/tree/master/ArcGISRuntimeSDKQt_QMLSamples/EditData/EditFeatureAttachments&lt;/A&gt;. Is this an option for you?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If not, it might be worth posting the question on the Qt forums -&amp;nbsp;&lt;A href="https://forum.qt.io/" target="_blank"&gt;https://forum.qt.io/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 15:35:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/post-image-to-website-servr-using-javascript/m-p/1005530#M3854</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2020-11-30T15:35:38Z</dc:date>
    </item>
  </channel>
</rss>

