This question is locked. New answers and comments are not allowed.
Hi guys
Can you please help me out. We want to be able to browse for files, and upload them to our server from the application.
We have 2 problems now:
1. We can access files in the photo library, but not files on the memory card, how do we access files that are not stored in the photo library?
2. We want to save the location of the file, and when the user eventually decides to submit the from, the application should go and find the file in the specific location and get its base64 data and post it to the server. We do not want to save the base64 data because that will make the application very big and duplicate files on the tablet.
Please help :)
Here is the code we currently use:
/ Wait for Cordova to connect with the device
//
document.addEventListener("deviceready",onDeviceReady,false);
// Cordova is ready to be used!
//
function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
}
// A button will call this function
//
function capturePhoto() {
// Take picture using device camera
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, saveToPhotoAlbum: true,
destinationType: destinationType.FILE_URI,
sourceType : Camera.PictureSourceType.CAMERA, encodingType: Camera.EncodingType.JPEG });
}
// A button will call this function
//
function getPhoto(source) {
// Retrieve image file location from specified source
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
destinationType: destinationType.DATA_URL,
sourceType: source });
}
// Called when a photo is successfully retrieved
//
function onPhotoDataSuccess(imageURL) {
// Uncomment to view the base64 encoded image data
console.log(imageURL);
}
// Called when a photo is successfully retrieved
//
function onPhotoURISuccess(imageData) {
// Uncomment to view the image file URI
console.log(imageData);
}
// Called if something bad happens.
//
function onFail(message) {
alert('Failed because: ' + message);
}
</script>
</head>
<body>
<button onclick="capturePhoto();">Capture Photo</button> <br>
<button onclick="getPhoto(pictureSource.SAVEDPHOTOALBUM);">From Photo Library</button><br>
<img style="display:none;width:60px;height:60px;" id="smallImage" src="" />
<img style="display:none;" id="largeImage" src="" />
</body>
</html>
Kind Regards,
Gerrit
Can you please help me out. We want to be able to browse for files, and upload them to our server from the application.
We have 2 problems now:
1. We can access files in the photo library, but not files on the memory card, how do we access files that are not stored in the photo library?
2. We want to save the location of the file, and when the user eventually decides to submit the from, the application should go and find the file in the specific location and get its base64 data and post it to the server. We do not want to save the base64 data because that will make the application very big and duplicate files on the tablet.
Please help :)
Here is the code we currently use:
/ Wait for Cordova to connect with the device
//
document.addEventListener("deviceready",onDeviceReady,false);
// Cordova is ready to be used!
//
function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
}
// A button will call this function
//
function capturePhoto() {
// Take picture using device camera
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, saveToPhotoAlbum: true,
destinationType: destinationType.FILE_URI,
sourceType : Camera.PictureSourceType.CAMERA, encodingType: Camera.EncodingType.JPEG });
}
// A button will call this function
//
function getPhoto(source) {
// Retrieve image file location from specified source
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
destinationType: destinationType.DATA_URL,
sourceType: source });
}
// Called when a photo is successfully retrieved
//
function onPhotoDataSuccess(imageURL) {
// Uncomment to view the base64 encoded image data
console.log(imageURL);
}
// Called when a photo is successfully retrieved
//
function onPhotoURISuccess(imageData) {
// Uncomment to view the image file URI
console.log(imageData);
}
// Called if something bad happens.
//
function onFail(message) {
alert('Failed because: ' + message);
}
</script>
</head>
<body>
<button onclick="capturePhoto();">Capture Photo</button> <br>
<button onclick="getPhoto(pictureSource.SAVEDPHOTOALBUM);">From Photo Library</button><br>
<img style="display:none;width:60px;height:60px;" id="smallImage" src="" />
<img style="display:none;" id="largeImage" src="" />
</body>
</html>
Kind Regards,
Gerrit