Commit 42d1b639 authored by Okthane's avatar Okthane

'final'

parent 62cac6a5
......@@ -8,6 +8,6 @@
<title>Merci pour votre participation</title>
</head>
<body>
<img src="img/.jpg" height="400px" >
</body>
</html>
\ No newline at end of file
File added
......@@ -63,8 +63,8 @@
<div id=conditions class="col-md-3 my-5 d-flex justify-content-center">
<ul class="list-group">
<li id="li-oneface" class="list-group-item list-group-item-secondary">Un seul visage<span></span></li>
<li id="li-format" class="list-group-item list-group-item-secondary">Format (jpg ou png)<span></span></li>
<li id="li-size" class="list-group-item list-group-item-secondary">Poids (< 1 Mo)<span></span></li>
<li id="li-format" class="list-group-item list-group-item-secondary">Format (jpg/png)<span></span></li>
<li id="li-taille" class="list-group-item list-group-item-secondary">Poids (< 1 Mo)<span></span></li>
</ul>
</div>
<div class="col-md-3 my-auto d-flex justify-content-center">
......
<?php
// phpinfo();
// echo json_encode(array("test"=>"ok")); die;
// die;
define('WHERE_TO_PUT','img_bg');
define('PATH_TO_BG', "img_bg");
define('TEMP','temp');
define('KEY','qtU9bhJqBxu4aYUsjJYJMWXC');
require_once "vendor/autoload.php";
if($_SERVER["REQUEST_METHOD"] == "POST")
{
if(isset($_FILES["photo"]) && $_FILES["photo"]["error"] == 0)
......@@ -44,11 +44,11 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
// $deletefile=unlink(TEMP.'/'.$newfilename);
//On crée et stocke l'image détourée
$fp = fopen('img_bg/'.pathinfo($newfilename, PATHINFO_FILENAME)."NO-BG.png", "wb");
$fp = fopen('img_bg/'.pathinfo($newfilename, PATHINFO_FILENAME).".png", "wb");
fwrite($fp, $res->getBody());
fclose($fp);
$path = 'img_bg/'.pathinfo($filename, PATHINFO_FILENAME)."NO-BG.png";
$path = 'img_bg/'.pathinfo($filename, PATHINFO_FILENAME).".png";
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
......
......@@ -33,8 +33,8 @@ var errorRemoveBackGround = true;
var unSeulVisage = false;
var format_correct = false;
const id_li_OneFace = "li-oneface"; var li_OneFace;
const id_li_Format = "li-oneface"; var li_format;
const id_li_taille = "li-oneface"; var li_taille;
const id_li_format = "li-format"; var li_format;
const id_li_taille = "li-taille"; var li_taille;
// SCRIPT ====================================================================================
......@@ -60,12 +60,18 @@ $(document).ready(function(){
inputFileUpload.change(function(){
unSeulVisage=false;
format_correct=false;
valide=false;
ImgBG.attr("src","");
li_format.removeClass("list-group-item-success list-group-item-danger").addClass("list-group-item-secondary");
li_OneFace.removeClass(" list-group-item-success list-group-item-danger").addClass("list-group-item-secondary");
li_taille.removeClass(" list-group-item-success list-group-item-danger").addClass("list-group-item-secondary");
});
//Requête pour les vérifications de sécurité & de format
$("#form").on("submit",function (event) {
event.preventDefault();
if(valide==false)
{ event.preventDefault();
var formData = new FormData(this);
console.log(inputFileUpload.attr('filename'));
......@@ -89,15 +95,16 @@ $(document).ready(function(){
.done(function(data){
errorFormat = data['error'];
data['errorMIME']?li_format.removeClass("list-group-item-secondary list-group-item-success").addClass("list-group-item-danger"):
li_format.removeClass("list-group-item-secondary list-group-item-danger").addClass("list-group-item-success");
data['errorSize']?li_taille.removeClass("list-group-item-secondary list-group-item-success").addClass("list-group-item-danger"):
li_taille.removeClass("list-group-item-secondary list-group-item-danger").addClass("list-group-item-success");
if(data['errorMIME']){li_format.removeClass("list-group-item-secondary list-group-item-success").addClass("list-group-item-danger");}
else{li_format.removeClass("list-group-item-secondary list-group-item-danger").addClass("list-group-item-success");}
console.log(data['errorSize'])
if(data['errorSize']){console.log(2); li_taille.removeClass("list-group-item-secondary list-group-item-success").addClass("list-group-item-danger");}
else{console.log(1); li_taille.removeClass("list-group-item-secondary list-group-item-danger").addClass("list-group-item-success");}
if(!errorFormat){
format_correct = true;
photoDetourage(formData);
}
})
})}
});
......@@ -112,9 +119,9 @@ $(document).ready(function(){
.done(function(response){
// let data = JSON.stringify(response);
// $("div#res").append(data);
if(!data["atraiter"]){window.open(URL_END, '_self');
let data = response;
console.log(data);
let studentIdRes = data['studentId'];
let prenom = data['prenom'];
let nom = data['nom'];
let mailCalcule = data["mailCalcule"];
......@@ -203,9 +210,9 @@ function sendMail(){
}
async function photoDetourage(formData){
// await findFaces(ID);
// if(unSeulVisage){
if (true){
await findFaces(ID);
if(unSeulVisage){
// if (true){
$.ajax({
//url de la requête
url: URL_DETOURAGE,
......@@ -213,8 +220,9 @@ async function photoDetourage(formData){
method: 'POST',
enctype: 'multipart/form-data',
data: formData,
cache: false,
cache: false,
dataType: "json",
contentType: false,
processData: false
......@@ -294,6 +302,7 @@ function get_base64(src){
k=k+1;
}
base_64 = string.slice(k+7);
console.log(base_64)
return base_64;
}
......
......@@ -37,12 +37,12 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
}
}
$maxsize = 1 * 1024 * 1024;
if(!($filename > $maxsize))
if(!($filesize > $maxsize))
{
$errorSize = false;
}
}
$error = $errorMIME&&$errorSize;
$error = $errorMIME || $errorSize;
$data = array(
"errorMIME" => $errorMIME,
......
<?php
if($_SERVER["REQUEST_METHOD"]=="POST"){
$data = array(
"dossier_valide" => false,
"atraiter" => true,
"studentId" => $_POST['studentId'],
"prenom" => "jean-patrick",
"nom" => "doe.remifa.sollasi",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment