[英]How to show image taken from camera in Cordova? (Xcode/iOS)
我可以訪問相機,甚至可以遠程保存圖像,但是我想在上傳之前在屏幕上顯示圖像。
打開設備攝像頭的功能是:
function capturePhoto() {
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 10, width: 412, height: 412, correctOrientation: 1, saveToPhotoAlbum: 1});
}
最初拍攝照片后觸發的功能是:
function uploadImage() {
imageURI = lastImage;
// Get image handle
var smallImage = document.getElementById('smallImage')
smallImage.src = "data:image/jpeg;base64," + imageURI;
var fail, ft, options, params, win;
// callback for when the photo has been successfully uploaded:
var success = function(response) {
//alert(tags);
alert("Photo Saved");
};
// callback if the photo fails to upload successfully.
var fail = function(error) {
alert("An error has occurred: Code = " + error.code);
alert(FileTransferError.CONNECTION_ERR);
};
//FILE UPLOAD SCRIPTS
options = new FileUploadOptions();
options.fileKey = "my_image";
options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
options.mimeType = "text/plain";
params = {
val1: tags,
val2: location
};
options.params = params;
ft = new FileTransfer();
ft.upload(imageURI, 'http://mysite.com/recieve.php', success, fail, options);
}
以及要顯示圖像的HTML:
<img style="display :none;width:60px;height:60px;" id="smallImage" src="" />
我假設這條線有問題
smallImage.src = "data:image/jpeg;base64," + imageURI;
但我不確定該如何解決。
有人會知道如何修改嗎?
我知道了。
我換了線
smallImage.src = "data:image/jpeg;base64," + imageURI;
太
smallImage.src = imageURI;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.