Commit 4e2986ec authored by Okthane's avatar Okthane

Renvoyer_image_requête

parent 1e38c61d
......@@ -20,7 +20,6 @@
<!-- API TenserFlow -->
</head>
<body>
<div class="site-header-main">
<div id="logo-header"></div>
<div class="site-branding">Titre de la page</div>
......@@ -55,9 +54,9 @@
const inpFile = document.getElementById("fileUpload");
const previewImage = document.getElementById("img-ID");
// inpFile.addEventListener("change", function (){
inpFile.addEventListener("change", function (){
const file = inpFile.files[0];
console.log("ok");
if (file){
const reader = new FileReader();
console.log("ok");
......@@ -67,7 +66,7 @@
reader.readAsDataURL(file);
}
// });
});
</script>
</div>
......
......@@ -4,7 +4,7 @@
define('WHERE_TO_PUT','img_bg');
define('PATH_TO_BG', "img_bg");
die;
require_once "vendor/autoload.php";
if($_SERVER["REQUEST_METHOD"] == "POST")
......@@ -40,10 +40,18 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
$fp = fopen('img_bg/'.pathinfo($filename, PATHINFO_FILENAME)."NO-BG.png", "wb");
fwrite($fp, $res->getBody());
fclose($fp);
$path = 'img_bg/'.pathinfo($filename, PATHINFO_FILENAME)."NO-BG.png";
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
$data = array(
"src" => PATH_TO_BG."/".pathinfo($filename, PATHINFO_FILENAME)."NO-BG.png"
"témoin"=>"ok",
"src" => $base64
);
echo json_encode($data);
}
}
}
......
......@@ -83,10 +83,7 @@ $(document).ready(function(){
//Affichage de la photo
$("#img-ID2").attr('src',data['src']);
})
// $("#img-ID2").attr('src','img_bg\\pierremarqueno-bg.png')
});
});
});
// FONCTIONS ================================================================================
......
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