【发布时间】:2016-06-15 14:44:22
【问题描述】:
在cordova(3.6.3) 版本中正常上传图库图片。升级 cordova6.1.1(Android 平台 5.1.1)图库图片无法正确上传。我可以从图库中选择图像,但所选图像在 UI 中不可见。捕获的相机图像正在 UI 中更新。从图库中选择的图像未更新。我已经检查了 fileEntry.js var localURL = this.toInternalURL();获取 url cdvfile://localhost/content/media/external/images/media/506 和旧的 cordova(3.6.3) 版本的 url 似乎是 content://media/external/images/media/511。
html code:
<div><a id="fromGallery" onclick="getPhoto(pictureSource.PHOTOLIBRARY);"></a></div>
js代码:
document.addEventListener("deviceready",onDeviceReady,false);
function onDeviceReady()
{
pictureSource = navigator.camera.PictureSourceType;
destinationType = navigator.camera.DestinationType;
}
function getPhoto(source) {
// Retrieve image file location from specified source
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: source });
}
function onPhotoURISuccess(imageurl){
imagesize(imageuri)
largeImage.src = imageURI;
}
var imagesize = function(imagedata){
window.resolveLocalFileSystemURI(imagedata,function(fileEntry){
**fileEntry.file(function(fileObj)**{
});
});
};
fileEntry.file 之后代码未执行。 我检查了 FileEntry.js 中的 FileEntry.prototype.file 方法并警告 localURL。 从 cordova 版本 3.6.3(content://media/external/images/media/511) 和 6.1.1(cdvfile://localhost/content/media/external/images/media/506) 获取不同的 url。 请提出问题的解决方案
【问题讨论】:
-
能否更准确地说明您的问题?有示例代码吗?
-
在下面查看我的答案。
-
更新了我的 html 和 js 代码。为我的问题提供一些解决方案
-
@manikandangopal 你试过我的答案了吗?
-
我试过下面提到的代码。那没起效。除此以外的任何想法