上傳圖片圖片在cordova(3.6.3)版本中正常工作。升級後cordova6.1.1(Android平臺5.1.1)圖庫圖片無法正確上傳。我可以從圖庫中選擇圖像,但所選圖像在用戶界面中不可見。捕獲的相機圖像在UI中得到更新。從圖庫中選擇的圖像沒有更新。我檢查過fileEntry.js var localURL = this.toInternalURL();獲取url cdvfile:// localhost/content/media/external/images/media/506和舊的cordova(3.6.3)版本url好像是內容:// media/external/images/media/511。cordova6.1.1(Android平臺5.1.1)圖庫圖片上傳不正確
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。 請提出問題的解決方案
你能更精確地解答你的問題嗎?任何示例代碼? – Gandhi
請在下面查看我的答案。 –
更新了我的html和js代碼。給我的問題一些解決方案 –