Appgyver /科尔多瓦:无法显示拍摄的图像 [英] Appgyver/Cordova: Not able to display captured image
问题描述
我能够成功地抓住从照片库以及摄像头和能够将图像使用的的文件传输的插件的,为他们节省。但是,这不是为工作code的唯一片显示图像:(当我提醒的 ImageURI 的,它给了我下面的路径:
I am able to successfully grab the image from photo library as well as camera and able to sent them to server using FileTransfer plugin, for saving them. But the only piece of code that is not working for is displaying the Image :( When I alert the ImageURI, it gives me the below path:
file://storage/sdcard0/Android/data/com.apgyver.freshandroid/cache/.Pic.jpg
我不知道如果我错过任何插件或者一些片code的?
I am not sure if I am missing any plugin or maybe some piece of code?
function getImage() {
// 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.PHOTOLIBRARY
}
);
}
function uploadPhoto(imageURI) {
//alert(imageURI); return false;
var image = document.getElementById('myImage');
image.src = imageURI;
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType="image/jpeg";
var params = new Object();
params.value1 = "test";
params.value2 = "param";
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(imageURI, url, win, fail, options);
}
它确实路径分配给的src
,但无法显示图像。
感谢您的帮助。
推荐答案
您必须缺少的 IMG 的id为的 MYIMAGE 的有宽度和高度的设置为某个值,以便它是可见的,并且给出显示:块
。您code严格遵循从相机插件使用的例子code和,因为它进入到正确的服务器,你应该有所有的插件及功放;需要的权限。
You must be missing the img element with id myImage which has width and height set to some value so that it is visible, and is given display: block
. Your code follows strictly the code from the examples of the Camera plugin usage and since it goes correctly to the server you should have all the plugins & permissions needed.
这篇关于Appgyver /科尔多瓦:无法显示拍摄的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!