Forked from muhafazakar/Cordova plugin camera foto cek kayit et server e jquery ajax ile yükle
Last active
November 15, 2016 05:49
-
-
Save mustafat0k/3dfa7c330727d4b18f14f36e4181fd90 to your computer and use it in GitHub Desktop.
Cordova Camera Plugin Cordova plugin camera foto cek kayit et server e jquery ajax ile yükle cordova-plugin-camera upload jquery ajax to server request
This file contains hidden or 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