AndroidDeveloper501
Lurker
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:
I'm calling the events defined above from inside the webview like this:
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...
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'});
});
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>
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...