【发布时间】:2014-02-01 23:34:53
【问题描述】:
我有一个 jquery 移动应用程序(phonegap 构建)。我有一个函数可以从设备的照片库中获取图像的 uri。我将 uri 作为字符串存储在本地存储中,因此下次打开页面时,图像会使用 uri 显示。所有这一切都很好(我没有得到图像的 Data-UrI,因为我不想用完本地存储,而且我当然不想将图像上传到服务器,因为应用程序正在使用学校(隐私问题)。不过,在设备上很好。在我对应用程序进行更新之前,一切正常。安装更新后,图像的 URI 会发生变化。如何获得所选图片的静态 URI。这是我用来从图库中获取图像的代码。:
// JavaScript Document //Get Picture stuff
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, destinationType:
destinationType.FILE_URI, sourceType:Camera.PictureSourceType.SAVEDPHOTOALBUM});
var pictureSource; // picture source
var destinationType; // sets the format of returned value
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
function onPhotoURISuccess(imageURI) {
// Uncomment to view the image file URI
console.log(imageURI);
localStorage.setItem("piclink", imageURI)
// Get image handle
var largeImage = document.getElementById('largeImage');
// Unhide image elements
largeImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
largeImage.src = imageURI;
}
// Called if something bad happens.
function onFail(message) {alert('Failed because: ' + message);
}
我应该提到,我应用的更新不会对相机代码进行任何更改。所有数据都很好地保存在本地存储中,我可以通过控制台看到它保存并调用 URI 没有问题,但是在更新后的 URI 路径中,路径发生了变化(一大串数字和破折号)。 bTW,安卓版没有问题。任何帮助将不胜感激
【问题讨论】:
标签: jquery ios camera phonegap-build