Commit 1e38c61d authored by Okthane's avatar Okthane

Affichage_dimage_memoire-ok

parent fbfab7a2
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="style.css">
<!-- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" /> -->
<!-- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> -->
<script src="tensorflow.js"></script> <script src="tensorflow.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/blazeface"></script> <script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/blazeface"></script>
<script src="jquery.js"></script> <script src="jquery.js"></script>
...@@ -23,37 +28,64 @@ ...@@ -23,37 +28,64 @@
</div> </div>
<div class="container"> <div class="container">
<div class ="div-ID div-photo" > <div class ="div-ID div-photo" >
<img id="img-ID" src="" height="150em"/> <img name ="im_ID" id="img-ID" src="" height="150em"/>
<img id="img-ID2" src="" height="150em"/> <img id="img-ID2" src="" height="150em"/>
<div id="div-filename"></div> <div id="div-filename"></div>
</div> </div>
</div> </div>
<div class="div-form"> <div class="div-form">
<form id ="form" action="" method="" enctype="multipart/form-data"> <form id ="form" action="" method="" enctype="multipart/form-data">
<!-- <label for="fileUpload">Fichier:</label> --> <!-- <label for="fileUpload">Fichier:</label> -->
<div class="div-btn-form"> <div class="div-btn-form">
<input type="file" name="photo" id="fileUpload" required="required" class="btn-form" hidden> <input type="file" name="photo" id="fileUpload" required="required" class="btn-form" accept="image/png, image/jpeg" onchange="document.im_ID.src=this.value;">
<button onclick="defaultBtnActive()" class="btn-form" id="custom-fileUpload">Choisissez une photo</button> <!-- <button onclick="defaultBtnActive()" class="btn-form" id="custom-fileUpload">Choisissez une photo</button> -->
</div>
<div class="div-btn-form">
<input id="btnSubmit" type="submit" name="submit" value="Upload" class="btn-form">
</div> </div>
</form>
<script> <script>
const defaultBtn = document.querySelector('#fileUpload'); const defaultBtn = document.querySelector('#fileUpload');
const customBtn = document.querySelector("#custom-fileUpload"); const customBtn = document.querySelector("#custom-fileUpload");
function defaultBtnActive(){ function defaultBtnActive(){
defaultBtn.click(); defaultBtn.click();
} }
const inpFile = document.getElementById("fileUpload");
const previewImage = document.getElementById("img-ID");
// inpFile.addEventListener("change", function (){
const file = inpFile.files[0];
if (file){
const reader = new FileReader();
console.log("ok");
reader.addEventListener("load", function(){
previewImage.setAttribute("src", this.result);
});
reader.readAsDataURL(file);
}
// });
</script> </script>
<div class="div-btn-form">
<input id="btnSubmit" type="submit" name="submit" value="Upload" class="btn-form">
</div>
</form>
</div> </div>
<div id="div"> <div id="div">
<p><strong>Note:</strong> Seuls les formats .jpg et .png sont autorisés jusqu'à une taille maximale de 5 Mo.</p> <p><strong>Note:</strong> Seuls les formats .jpg et .png sont autorisés jusqu'à une taille maximale de 5 Mo.</p>
<p id="p-status"><strong>Statut :</strong><span id="span-status"></span></p> <p id="p-status"><strong>Statut :</strong><span id="span-status"></span></p>
</div> </div>
<div class = "container"> <div class = "form-container" id="email-container">
<div class="title-container"> <h2>Choix de l'adresse électronique</h2></div>
<div class="form-emails">
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
<label for="vehicle1"> </label><br>
<input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
<label for="vehicle2"> </label><br>
<input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
<label for="vehicle3"></label><br>
</div>
</div> </div>
</body> </body>
</html> </html>
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
define('WHERE_TO_PUT','img_bg'); define('WHERE_TO_PUT','img_bg');
define('PATH_TO_BG', "img_bg"); define('PATH_TO_BG', "img_bg");
die;
require_once "vendor/autoload.php"; require_once "vendor/autoload.php";
if($_SERVER["REQUEST_METHOD"] == "POST") if($_SERVER["REQUEST_METHOD"] == "POST")
......
...@@ -8,7 +8,8 @@ const canva = "canvas"; ...@@ -8,7 +8,8 @@ const canva = "canvas";
const idConsole = "div";var Console; const idConsole = "div";var Console;
const idFileUpload = "custom-fileUpload"; var btnFileUpload; const idFileUpload = "fileUpload"; var inputFileUpload;
const idCustomFileUpload = "custom-fileUpload"; var btnCustomFileUpload;
const idBtnSubmit = 'btnSubmit';var btnSubmit; const idBtnSubmit = 'btnSubmit';var btnSubmit;
const idStatut = "span-status"; const idStatut = "span-status";
...@@ -21,17 +22,21 @@ var errorRemoveBackGround = true; ...@@ -21,17 +22,21 @@ var errorRemoveBackGround = true;
$(document).ready(function(){ $(document).ready(function(){
btnFileUpload = $("#"+idFileUpload); inputFileUpload = $("#"+idFileUpload);
console.log(inputFileUpload.val());
btnCustomFileUpload = $("#"+idCustomFileUpload);
btnSubmit = $("#"+idBtnSubmit); btnSubmit = $("#"+idBtnSubmit);
Console = $("#"+idConsole); Console = $("#"+idConsole);
$("#form").on("submit",function (event) { $("#form").on("submit",function (event) {
event.preventDefault(); event.preventDefault();
var formData = new FormData(this); var formData = new FormData(this);
console.log(inputFileUpload.attr('filename'));
$.ajax({ $.ajax({
//url de la requête //url de la requête
url: URL_CHECK_ID, url: URL_CHECK_ID,
method: 'POST', method: 'POST',
enctype: 'multipart/form-data', enctype: 'multipart/form-data',
data: formData, data: formData,
...@@ -44,6 +49,7 @@ $(document).ready(function(){ ...@@ -44,6 +49,7 @@ $(document).ready(function(){
.done(function(data){ .done(function(data){
console.log(data); console.log(data);
src = data['src']; src = data['src'];
console.log('src');
errorUpload = data['error']; errorUpload = data['error'];
Console.empty(); Console.empty();
Console.append(data['message']); Console.append(data['message']);
...@@ -79,12 +85,14 @@ $(document).ready(function(){ ...@@ -79,12 +85,14 @@ $(document).ready(function(){
}) })
// $("#img-ID2").attr('src','img_bg\\pierremarqueno-bg.png') // $("#img-ID2").attr('src','img_bg\\pierremarqueno-bg.png')
}); });
}); });
// FONCTIONS ================================================================================ // FONCTIONS ================================================================================
async function findFaces() { async function findFaces() {
btnFileUpload.prop('disabled',true); btnCustomFileUpload.prop('disabled',true);
btnSubmit.prop('disabled',true); btnSubmit.prop('disabled',true);
console.log('_findFaces()'); console.log('_findFaces()');
const model = await blazeface.load(); const model = await blazeface.load();
...@@ -125,7 +133,12 @@ async function findFaces() { ...@@ -125,7 +133,12 @@ async function findFaces() {
$("#"+idStatut).append("No Face(s) Found"); $("#"+idStatut).append("No Face(s) Found");
} }
btnSubmit.prop('disabled',false); btnSubmit.prop('disabled',false);
btnFileUpload.prop('disabled',false); btnCustomFileUpload.prop('disabled',false);
}
function getFile(filePath) {
return filePath.substr(filePath.lastIndexOf('\\') + 1) ;
} }
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