0

Trying to send the base64 image to server through restwebservice. Problem is i didnt get any error in logcat and its not hitting the server. Server url is correct. and i tested service using webapp its working fine. But in phonegap its problem

function Test() { alert(imgByte);

/**imgByte is in base64 format -->pic.src = "data:image/png;base64," + imageURI; imgByte = pic.src;*/ $.ajax({ type : "POST", url : IMGURL, data : { image : imgByte }, delay : 3, dataType : "text", cache : false, error : function(xhr, ajaxOptions, thrownError) { debugger; }, success : function(response, status, xhr) { alert("haiSuccess1"); response = xhr.responseText; var responseArray = JSON.parse(response); if (responseArray.status == "success") { alert("haiSuccess"); } } }); } 
3
  • Have you tried reproducing the issue in a browser or something like Ripple? Commented Apr 17, 2013 at 8:49
  • @KevinBoyle i didnt get any type of parsing issue.. but the problem is the function is not going to success state. I checked log cat no error Commented Apr 17, 2013 at 8:56
  • Can you confirm that request is reaching your server? Commented Apr 17, 2013 at 9:30

2 Answers 2

1

Because you are using a Phonegap a cross domain call should not be a problem.

  1. Is your picture taken successfully and can you see it?
  2. Check you are receiving data on a server side.
  3. In case there's a problem with a point 1. check if you can send any REST request to your server
  4. Check that you have enough permission to access an internet from your mobile app

This is a working code I used in one of my examples.

Javascript :

navigator.camera.getPicture(success, fail, {quality: 45, sourceType: src}); function success(imageData) { var url = some_location; var params = {image: imageData}; // send the data $.post(url, params, function(data) { alert('sent'); // Display the selected image on send complete $('#image').attr('src', 'data:image/jpeg;base64,' + params['image']); }); } function fail(error) { alert(error); } 

PHP :

<?php if ($_REQUEST['image']) { // convert the image data from base64 $imgData = base64_decode($_REQUEST['image']); // rest of the code } ?> 

But my guess is you are receiving this error: Error 414 (Request-URI Too Large). You are trying to send to large picture. To fix this lower picture quality to lowest point and try to send it. If it works correctly then this is your problem.

Sign up to request clarification or add additional context in comments.

Comments

0

Its not Phonegap problem. By default your webserver (Server side code runnning on server), they restricted the Incoming data size (not file size ) to some fixed size. You should increase to get this to be work.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.