Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old August 16th, 2010, 04:54 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Aug 2010
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Titanium SDK: Image Upload

Hi everyone, I'm new here

I have a problem that is bugging me very much, I have to solve it very urgently, but nobody replies on the Appcelerator forums so I found this one on Google and thought I give it a try.

I'm using a webview, and I'm calling titanium events from the javascript inside the webview. I need to upload images from the photo gallery, or camera, to my server.

Here is my code:

Code:
var image;
 
Ti.App.addEventListener('select_button', function()
{
    Titanium.Media.openPhotoGallery({
 
        success:function(event)
        {
            image = event.media;
        },
        cancel:function(){},
        error:function(){},
        allowImageEditing:true
    });
});
 
Ti.App.addEventListener('upload_button', function()
{
    var xhr = Titanium.Network.createHTTPClient();
 
    xhr.onerror = function(e){alert('Error');};
    xhr.setTimeout(200000);
    xhr.onload = function(e){alert(this.responseText)};
    xhr.onsendstream = function(e){};
    xhr.open('POST','http://domain.com/upload');
    xhr.send({media:image,title:'test'});
});
I'm calling the events defined above from inside the webview like this:

Code:
<p onclick='send("select_button");return false;'>Select Button</p>
<p onclick='send("upload_button");return false;'>Upload Button</p>
<script>
function send(event) {
    Ti.App.fireEvent(event);
}
</script>
I have TWO problems, first and most important, when I choose an image, everythings fine, and I click "Upload", the log shows this:

paste.ly - 5Sf


SECOND, how can I make the WebView <-> titanium communication NOT interrupted by clicking a link inside the WebView ?
(thus, going to another page, this other page also has the event callers, but they are not working.)


Thanks in advance...

Advertisements
AndroidDeveloper501 is offline  
Reply With Quote
sponsored links
Reply
Tags
titanium, upload, upload image, xhr


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 03:05 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.