Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8843325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:11:32+00:00 2026-06-14T11:11:32+00:00

This must be close but I can’t figure out what’s causing the error. In

  • 0

This must be close but I can’t figure out what’s causing the error.

In my Titanium app, I have a Webview with a canvas element and this code:

function getImageData() {
    return canvas.toDataURL('image/png');
}

I am moving that data to the Titanium app like this:

var imageBase64data = webview.evalJS('getImageData()')

The data looks good starting with “data:image/png;base64,”…

Then in Titanium, I have a logged-in drupal session and call this function:

function uploadImage(imageBase64data, callback) {

    var url = REST_PATH + "file.json";

    var file = { 
        filename: utils.createRandomString() + ".png",
        file: imageBase64data
//      uid: Titanium.App.Properties.getString("userUid"),
//      filesize: ""+Titanium.Utils.base64decode(imageBase64data).length,
    };


    var xhr = Titanium.Network.createHTTPClient({timeout: 30000});

    xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

    var authString = Titanium.App.Properties.getString("userSessionName")+'='+Titanium.App.Properties.getString("userSessionId");
    xhr.setRequestHeader("Cookie", authString);

    xhr.onload = function() {
        if(xhr.status == 200) {

            var response = xhr.responseText;

            callback(response);
        }
    };

    xhr.onerror = function(e) {
      alert("There was an error: " + e.error);

      Ti.API.info(JSON.stringify(this));
    };    

    xhr.open("POST", url);
    xhr.send(file);
}

xhr.onerror is being called with e.error = “undefined”

The trace looks like this:

{
  "responseData":{},
  "readyState":4,
  "connected":true,"UNSENT":0,"DONE":4,"HEADERS_RECEIVED":2,"OPENED":1,"LOADING":3,
  "responseText":null,"status":406
}

I think authentication is working because I was previously getting a “need authentication” error until I added the Cookie header.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:11:33+00:00Added an answer on June 14, 2026 at 11:11 am

    That was with the installation provided by Drupanium. I just did a fresh Drupal and fresh Services 3 install and my file is uploading nicely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This must be simple, but I can't seem to figure it out. I am
This must be a dumb question, but I cannot figure it out. I also
I'm sure this must be something simple, but I can't quite work out what's
It must be obvious, but I can't figure it out. I spent almost a
This must be a duplicate. But with so many NSPredicate questions out there, I
This must have an obvious solution, but I'm stumped. We are developing an application
This must be very simple. But I just can't seem to find the proper
This must be so simple, but I can't find it: How do you restore
I must apologize if this is a duplicate question, but I can't seem to
This must be a stupid question, but nevertheless I find it curious: Say I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.