日期:2014-05-16 浏览次数:20337 次
function onPhotoURISuccess(imageURI) {
// 取消注释以查看图片文件的URI
// console.log(imageURI);
// 获取图片句柄
var largeImage = document.getElementById('largeImage');
// 取消隐藏的图像元素
largeImage.style.display = 'block';
// 显示拍摄的照片
// 使用内嵌CSS规则来缩放图片
largeImage.src = imageURI;
// uploadPhoto(imageURI);
}
function getPhoto(source) {
// 从设定的来源处获取图像文件URI
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,destinationType: destinationType.FILE_URI,sourceType: source });
}
function uploadPhoto(imageURI) {
var options = new FileUploadOptions();
options.fileKey="image";
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType="image/jpeg";
var params = new Object();
params.value1 = "jpeg";
// params.value2 = "param";
options.params = params;
var ft = new FileTransfer();
ft.upload(imageURI, "http://192.168.1.200/xinshi/upload_image.php", win, fail, options);
}
<div data-role="dialog" id="logout">
<a href="#" data-role="button" onclick="uploadPhoto(imageURI);">上传图片</a>
<a href="#" data-role="button" data-theme="b" onclick="getPhoto(pictureSource.PHOTOLIBRARY);">从相册选择</a>
<div >