2012-04-23 34 views
0

我的问题是,我需要拍一张照片,并将其发送到PHP(服务器),但我尝试用不同的代码,我没有有预期的响应我需要帮助拍摄Phonegap(Android)上的照片,并将其发送到php(服务器)

function startCamera() { 

      navigator.camera.getPicture(onSuccess, onFail, { 
       quality: 50,  
       destinationType: navigator.camera.DestinationType.DATA_URL 
      }); 
      function onSuccess(imageData){  

       alert(imageData); 
       var url = "http://www.trueware.mx/eduardo/mybiometrics_online/foto.php?callback=parseRequest&foto="+imageData; 
       var script = document.createElement('script'); 
       script.setAttribute('src', url); 
       document.getElementsByTagName('head')[0].appendChild(script); 
      } 
      function onFail(message) 
      {  
       alert('Failed because: ' + message); 
      } 
     } 
     function parseRequest(response) 
     { 
      try 
      { 
       console.log(response); 
       for (var i=0; i < response.length; i++) { 
         var dato = response[i].foto; 
         alert(dato); 
         var foto=Base64.decode(response[i].foto); 
         var imagen = document.createElement('img'); 
         imagen.setAttribute('src',foto); 
         document.getElementById('cabezera').appendChild(imagen); 
       } 
      } 
      catch(an_exception) 
      { 
       document.write("Error de Conexion"); 
      } 
     } 

所以我需要帮助和做一个例子。

的JavaScript中的一部分和PHP的一部分

如果有人能帮助我,我将是gratefull

回答

相关问题