Commit 7a62bc72 authored by Okthane's avatar Okthane

finitions

parent b6947caa
......@@ -55,7 +55,7 @@
<div class ="row d-flex justify-content-center div-ID div-photo" >
<div id ="dropcontainer" class ="row d-flex justify-content-center div-ID div-photo" >
<div class="col-md-3 my-auto d-flex justify-content-center" >
<img name ="im-ID" id="img-ID" src="" height="150em"/>
</div>
......@@ -93,6 +93,7 @@
console.log("ok");
reader.addEventListener("load", function(){
previewImage.setAttribute("src", this.result);
base64 = get_base64(this.result);
});
reader.readAsDataURL(file);
// findFaces("img-ID");
......@@ -105,6 +106,7 @@
console.log("ok");
reader.addEventListener("load", function(){
previewImage.setAttribute("src", this.result);
base64 = get_base64(this.result);
});
reader.readAsDataURL(file);
// findFaces("img-ID");
......
......@@ -29,7 +29,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
'multipart' => [
[
'name' => 'image_file',
'contents' => fopen(TEMP.'/'.$newfilename, 'r')
'contents' => fopen($_FILES["photo"]["tmp_name"], 'r')
],
[
'name' => 'size',
......@@ -41,7 +41,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
]
]);
// On supprime l'image intermédiaire
$deletefile=unlink(TEMP.'/'.$newfilename);
// $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");
......
......@@ -16,7 +16,7 @@ const canva = "canvas";
const idConsole = "span-status";var Console;
var base64 = "";
const idFileUpload = "fileUpload"; var inputFileUpload;
const idCustomFileUpload = "custom-fileUpload"; var btnCustomFileUpload;
......@@ -59,6 +59,7 @@ $(document).ready(function(){
format_correct=false;
ImgBG.attr("src","");
});
//Requête pour les vérifications de sécurité & de format
$("#form").on("submit",function (event) {
event.preventDefault();
......@@ -84,8 +85,6 @@ $(document).ready(function(){
})
.done(function(data){
console.log(data);
src = data['src'];
console.log('src');
errorFormat = data['error'];
var message = data['message']
if(!errorFormat){
......@@ -155,11 +154,30 @@ $(document).ready(function(){
}
})
$("#dropcontainer").ondragover = $("#dropcontainer").ondragenter = function(evt) {
evt.preventDefault();
};
$("#dropcontainer").ondrop = function(evt) {
evt.preventDefault()
// pretty simple -- but not for IE :(
idFileUpload.files = evt.dataTransfer.files;
// If you want to use some of the dropped files
const dT = new DataTransfer();
dT.items.add(evt.dataTransfer.files[0]);
dT.items.add(evt.dataTransfer.files[3]);
fileInput.files = dT.files;
evt.preventDefault();}
});
// FONCTIONS ================================================================================
function sendMail(){
console.log($("input[name=\"mail\"]:checked").val());
var mail = $("input[name=\"mail\"]:checked").val();
......@@ -179,9 +197,9 @@ function sendMail(){
// window.close();
}
async function photoDetourage(formData){
async function photoDetourage(base64){
// await findFaces(ID);
console.log("await");
// if(unSeulVisage){
if (true){
$.ajax({
//url de la requête
......@@ -189,7 +207,7 @@ async function photoDetourage(formData){
method: 'POST',
enctype: 'multipart/form-data',
data: formData,
data: base64,
cache: false,
dataType: "json",
......@@ -241,7 +259,7 @@ async function findFaces(idImage) {
function getParameter(url){
L = url.length;
l=0;
l = 0;
parameter="";
for (var k = 0; k<L; k++){
l=k
......@@ -255,7 +273,7 @@ function getParameter(url){
while(l<L&& url[l]!="&")
{
parameter+=url[l];
l=l+1;
l = l+1;
}
// console.log(parameter);
return parameter;
......@@ -265,4 +283,17 @@ function getFile(filePath) {
return filePath.substr(filePath.lastIndexOf('\\') + 1) ;
}
function get_base64(src){
var string = src;
var k = 0;
var base_64;
while (string.slice(k,k+7)!="base64," && k<100)
{
k=k+1;
}
base_64 = string.slice(k+7);
return base_64;
}
<?php
<?php
//dossier temporaitre pour les images
define('PATH_TO_TEMP', "temp");
......@@ -41,12 +41,12 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
{
//echo $_FILES["photo"]["name"] . " existe déjà.";
$error = false;
move_uploaded_file($_FILES["photo"]["tmp_name"], PATH_TO_TEMP."/".$newfilename);
// move_uploaded_file($_FILES["photo"]["tmp_name"], PATH_TO_TEMP."/".$newfilename);
$message = $_FILES["photo"]["name"] . " existe déjà.";
}
else
{
move_uploaded_file($_FILES["photo"]["tmp_name"], PATH_TO_TEMP."/".$filename);
// move_uploaded_file($_FILES["photo"]["tmp_name"], PATH_TO_TEMP."/".$filename);
// echo "Votre fichier a été téléchargé avec succès.";
// echo("<br></br>");
// echo "taille de la photo : ".$_FILES["photo"]["size"]." octets";
......@@ -84,3 +84,4 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
echo json_encode($data);
}
?>
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