John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

Photo just taken, how to add to a photo album?

Have you tried testing it because it doesnt work unless Im missing something here?

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

Photo just taken, how to add to a photo album?

Hi Marina, have you tried looking into this code? Is there anything else I need to do like in my settings to make this work with 'data.imageURI' because I tried several different settings and all I get is a thin gray border (as shown in the above screenshot from my iPhone)??

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Photo just taken, how to add to a photo album?

Please share the app with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a so we can test it.

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

Photo just taken, how to add to a photo album?

Marina, yes I shared the app with you guys. Actually, I just tried playing with that previous code I was talking about and somehow it now takes the photos, but when I implement this code (sending the photo to my server), the page doesnt even load anymore:

-------------------------------------------------
Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Photo just taken, how to add to a photo album?

Hi John! Sorry for delay with resolving this issue, but we need more time. I'll update when have more information.

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

Photo just taken, how to add to a photo album?

ok so I've been playing with the PhoneGap code a bit more and got a little progress, but I got stuck at an error I have no idea about. I rewrote the code a bit and it now looks like this:

// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);

Code: Select all

     // Cordova is ready 
     // 

     function onDeviceReady() { 

         // Retrieve image file location from specified source 
         navigator.camera.getPicture(uploadPhoto, 
                                     function(message) { alert('get picture failed'); }, 
                                     { quality: 100,  
                                     destinationType: navigator.camera.DestinationType.FILE_URI, 
                                     sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY } 
                                     ); 

     } 

     function uploadPhoto(imageURI) { 
         try 
         { 
         var options = new FileUploadOptions(); 
         options.fileKey="file"; 
         options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1); 
         options.mimeType="image/png"; 

         // Retrieve driver id in order to send picture file with the driver id 
        var g=localStorage.getItem('driver_master_id');  

         var params = {}; 
         //params.value1 = "value"; 

         params.id=g; 

         options.params = params; 

         var ft = new FileTransfer(); 
         ft.upload(imageURI, encodeURI("[url=http://ec2-54-225-36-84.compute-1.amazonaws.com/m/DriverMobile/UploadPictures]http://ec2-54-225-36-84.compute-1.ama...[/url]"), win, fail, options); 
         } 
         catch(err) 
         { 
             console.log(err); 
          } 
     } 

     function win(r) { 
         console.log("Code = " + r.responseCode); 
         console.log("Response = " + r.response); 
         console.log("Sent = " + r.bytesSent); 
     } 

     function fail(error) { 
         alert("An error has occurred: Code = " + error.source+ error.code); 
         //console.log("upload error source " + error.source); 
         //console.log("upload error target " + error.target); 
     } 

When I run this code, instead of letting me use the photos I took and loaded on the screen it took me through the phones PhotoLibrary instead. I want to change it - maybe I can get some help how I can grab the photos I took using this line of code (where do i integrate the above code to grab the photos from this code):

Appery('load_pics').append('Image ');

Besides that, heres the error Im getting with main code (1st code in this comment) im running:

Image

So right now I got two problems. 1) I'd like to grab the photos from my own album that Im creating instead of going to the Phones PhotoLibrary; and 2) How do I fix the error shown in my screenshot?

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

Photo just taken, how to add to a photo album?

ok so how are we doing with this? when can I expect to get a good JS code to work with? thanks...

Anton Artyukh5836028
Posts: 0
Joined: Wed May 08, 2013 12:57 pm

Photo just taken, how to add to a photo album?

Hi John,

Sorry for the delay.

1) because codesourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY /code
check this link.
2) please use this link for details.

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

Photo just taken, how to add to a photo album?

Hello everbody... after much time playing with this code from Phonegap this code finally worked with my AWS server (what it does is take a photo, and send an id (from a local storage variable) along with the pic file to the server:

// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);

Code: Select all

     // Cordova is ready 
     // 

     function onDeviceReady() { 

         // Retrieve image file location from specified source 
         navigator.camera.getPicture(uploadPhoto, 
                                     function(message) { alert('get picture failed'); }, 
                                     { quality: 50,  
                                     destinationType: navigator.camera.DestinationType.FILE_URI, 
                                     sourceType: navigator.camera.PictureSourceType.CAMERA } 
                                     ); 

     } 

     function uploadPhoto(imageURI) { 

        $.mobile.loading("show");  

         try 
         { 
         var options = new FileUploadOptions(); 
         options.fileKey="file"; 
         options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1); 
         options.mimeType="image/png"; 

             // Retrieve driver id in order to send picture file with the driver id 
        var g=localStorage.getItem('driver_master_id');  

         var params = {}; 
             //params.value1 = "value"; 

         params.id=g; 

         options.params = params; 

         var ft = new FileTransfer(); 
         ft.upload(imageURI, encodeURI("[url=http://someservername.com]http://someservername.com[/url]"), win, fail, options); 
         } 
         catch(err) 
         { 
             console.log(err); 
          } 
     } 

     function win (/*r*/) { 
        $.mobile.loading( "hide" );  
        alert("Thank You for submitting a load document photo. If you need to submit more load documents, please Click the Take Photos button until you have finished taking photos"); 
         //console.log("Code = " + r.responseCode); 
         //console.log("Response = " + r.response); 
         //console.log("Sent = " + r.bytesSent); 

     } 

     function fail(error) { 
          $.mobile.loading( "hide" );  
         alert("An error has occurred: Code = " + error.source+ error.code); 
         //console.log("upload error source " + error.source); 
         //console.log("upload error target " + error.target); 
     }
John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

Photo just taken, how to add to a photo album?

Thanks for everbody's input on this:)

Return to “Issues”