Created
April 10, 2016 22:57
-
-
Save AysadKozanoglu/f11ee6c9bb95111b33d36bfd56a053d4 to your computer and use it in GitHub Desktop.
Cordova Camera Plugin cordova-plugin-camera upload jquery ajax to server request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!-- Aysad Kozanoglu --> | |
<html> | |
<head> | |
<title>foto cek</title> | |
<style> | |
html { | |
-webkit-user-select: none; | |
} | |
</style> | |
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" /> | |
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script> | |
<script type="text/javascript" charset="utf-8" src="cordova.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
var pictureSource; // picture source | |
var destinationType; // sets the format of returned value | |
// Wait for device API libraries to load | |
// | |
function onLoad() { | |
document.addEventListener("deviceready", onDeviceReady, false); | |
} | |
// device APIs are available | |
// | |
function onDeviceReady() { | |
pictureSource=navigator.camera.PictureSourceType; | |
destinationType=navigator.camera.DestinationType; | |
} | |
// Called when a photo is successfully retrieved | |
// | |
function onPhotoDataSuccess(imageData) { | |
var smallImage = document.getElementById('smallImage'); | |
smallImage.style.display = 'block'; | |
smallImage.src = "data:image/jpeg;base64," + imageData; | |
fotoUpload(imageData); | |
} | |
// A button will call this function | |
// | |
function capturePhotoEdit() { | |
// Take picture using device camera, allow edit, and retrieve image as base64-encoded string | |
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 20, allowEdit: true, | |
destinationType: destinationType.DATA_URL }); | |
} | |
// Called if something bad happens. | |
// | |
function onFail(message) { | |
alert('Failed because: ' + message); | |
} | |
</script> | |
</head> | |
<body onload="onLoad()"> | |
<center> | |
<img src="logo.png" width="50%" border=0> | |
<br> | |
<h1>Entwicklungsumgebung</h1> | |
<br> | |
Kamera Photoschuss und upload Server | |
<br><br><br><br> | |
<button onclick="capturePhotoEdit();" style="height:60px;width:80%">Photo Schnappschuss</button> | |
<br><br><br> | |
<a href="http://5.45.96.121/upload/" target ="_blank"> <h2>Bilder auf dem Server ansehen </h2></a> | |
<br><br><br> | |
<div id="ajaxStatus"></div> | |
<img style="display:none;width:50%" id="smallImage" src="" /> | |
<br><br><font size="-2"> Erfinder: Levent Yakar <br> Architekt: Aysad Kozanoglu | |
<script type="text/javascript" charset="utf-8"> | |
$(document).ready(function(){ | |
$("#ajaxStatus").html("ein Bild aufnehmen"); | |
}); | |
function fotoUpload(imageData){ | |
//alert(imageData); | |
$.ajax({ | |
type: "POST", | |
url: "http://5.45.96.121/upload/up2.php", | |
data: { img_data:imageData}, | |
cache: false, | |
contentType: "application/x-www-form-urlencoded", | |
success: function (result) { | |
alert("upload OK: "+ result); | |
} | |
}); | |
$("#ajaxStatus").html("bild hochgeladen"); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you give me up2.php file?