我想放在一起的一个小phonegap应用程序上传图像到协作网站。我已经看过教程和API。到目前为止,我有捕获的图像,但我坚持把它送到服务器。我希望能够使用jQuery来完成Ajax。我的jquery似乎停止了图像捕获btn的工作,当我将它拿出btn作品并捕获图像时。除了jQuery之外,还有其他的方法可以做到这一点,或者我只是一个笨蛋而错过了一些东西?我对phonegap非常陌生。上传图片到服务器与phonegap(w/jQuery的AJAX)
$(document).ready(function() {
function capturePhoto() {
// Take picture using device camera and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50 });
}
function onFail(message) {
alert('Failed because: ' + message);
}
function onPhotoDataSuccess(imageData) {
var url = 'http://www.creativetree.co/phonegapupload.php';
var params = {image: imageData};
navigator.notification.alert('photo taken');
$.post(url, params, function(data) {
// Display the selected image on send complete
$('#image').attr('src', 'data:image/jpeg;base64,' + params['image']);
});
}
});
将PHP类似于正常,我以前使用$ _POST。我将使用什么来检索电话文件传输? – ChrisSherwood 2012-03-13 14:09:22
它会像ft.upload(imageURI,http://www.creativetree.co/phonegapupload.php“,win,fail,options); – gmh04 2012-03-13 14:44:22