Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Projet ISIS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MARQUE Pierre
Projet ISIS
Commits
876d653f
Commit
876d653f
authored
Mar 11, 2022
by
Okthane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Intégration de la fonction vérification
parent
c2443606
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
6 deletions
+73
-6
14110-full.png
14110-full.png
+0
-0
586345_qotsa-go-with-the-flow-hell-by-ankhacrow-on-deviantart_1000x707_h.jpg
...h-the-flow-hell-by-ankhacrow-on-deviantart_1000x707_h.jpg
+0
-0
index.php
index.php
+9
-2
script.js
script.js
+58
-3
upload.php
upload.php
+6
-1
No files found.
14110-full.png
0 → 100644
View file @
876d653f
525 KB
586345_qotsa-go-with-the-flow-hell-by-ankhacrow-on-deviantart_1000x707_h.jpg
0 → 100644
View file @
876d653f
110 KB
index.php
View file @
876d653f
...
...
@@ -7,15 +7,22 @@
<title>
Formulaire d'upload de fichiers
</title>
<script
src=
"jquery.js"
></script>
<script
src=
"script.js"
></script>
<!-- API TenserFlow -->
<script
src=
"https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"
></script>
<script
src=
"https://cdn.jsdelivr.net/npm/@tensorflow-models/blazeface"
></script>
</head>
<body>
<form
id =
"form"
action=
""
method=
"POST"
enctype=
"multipart/form-data"
>
<form
id =
"form"
action=
""
method=
""
enctype=
"multipart/form-data"
>
<h2>
Upload Fichier
</h2>
<div
id =
"div-ID"
>
<canvas
id=
"canvas"
></canvas>
<img
id=
"img-ID"
src=
""
/>
</div>
<label
for=
"fileUpload"
>
Fichier:
</label>
<input
type=
"file"
name=
"photo"
id=
"fileUpload"
>
<input
id=
"#btnSubmit"
type=
"submit"
name=
"submit"
value=
"Upload"
>
<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></p> -->
</form>
<div
id=
"div"
></div>
</body>
...
...
script.js
View file @
876d653f
// VARIABLES
const
URL_CHECK_ID
=
'upload.php'
;
const
ID
=
$
(
"#img-ID"
);
const
canva
=
$
(
"#canva"
);
// SCRIPT
$
(
document
).
ready
(
function
(){
$
(
"#form"
).
on
(
"submit"
,
function
(
event
)
{
event
.
preventDefault
();
var
formData
=
new
FormData
(
this
);
$
.
ajax
({
url
:
'upload.php'
,
enctype
:
'multipart/form-data'
,
//url de la requête
url
:
URL_CHECK_ID
,
method
:
'POST'
,
enctype
:
'multipart/form-data'
,
data
:
formData
,
cache
:
false
,
dataType
:
"json"
,
contentType
:
false
,
processData
:
false
})
.
done
(
function
(
response
){
//Traitement de la réponse
let
data
=
JSON
.
stringify
(
response
);
$
(
"div#div"
).
empty
();
$
(
"div#div"
).
append
(
data
);
//Affichage de la photo
})
// findFaces();
});
});
// FONCTIONS
async
function
findFaces
()
{
const
model
=
await
blazeface
.
load
();
const
img
=
ID
;
const
predictions
=
await
model
.
estimateFaces
(
img
,
false
);
if
(
predictions
.
length
>
0
)
{
console
.
log
(
"faces found"
)
console
.
log
(
predictions
);
document
.
getElementById
(
"status"
).
innerText
=
"Face(s) found!"
;
const
canvas
=
canva
;
canvas
.
width
=
img
.
width
;
canvas
.
height
=
img
.
height
;
// const ctx = canvas.getContext("2d");
// ctx.fillStyle = "rgba(250,225,6,0.5)";
// for (let i = 0; i < predictions.length; i++)
// {
// const start = predictions[i].topLeft;
// const end = predictions[i].bottomRight;
// const size = [end[0] - start[0], end[1] - start[1]];
// ctx.fillRect(start[0], start[1], size[0], size[1]);
// var landmark;
// for (let j = 0; j < predictions[i].landmarks.length; j++)
// {
// landmark = predictions[i].landmarks[j];
// ctx.beginPath();
// ctx.arc(landmark[0],landmark[1], 1, 0, 2*Math.PI,false);
// ctx.fill();
// ctx.lineWidth = 1;
// ctx.strokeStyle = '#ff0000';
// ctx.stroke();
// }
// }
}
else
{
document
.
getElementById
(
"status"
).
innerText
=
"No Face(s) Found"
;
}
}
upload.php
View file @
876d653f
<?php
define
(
"PATH_TO_ID"
,
""
);
// Vérifier si le formulaire a été soumis
if
(
$_SERVER
[
"REQUEST_METHOD"
]
==
"POST"
){
// Vérifie si le fichier a été uploadé sans erreur.
//format de la réponse
if
(
isset
(
$_FILES
[
"photo"
])
&&
$_FILES
[
"photo"
][
"error"
]
==
0
)
{
$allowed
=
array
(
"jpg"
=>
"image/jpeg"
,
"png"
=>
"image/png"
);
...
...
@@ -22,7 +26,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
if
(
in_array
(
$filetype
,
$allowed
))
{
// Vérifie si le fichier existe avant de le télécharger.
if
(
file_exists
(
$_FILES
[
"photo"
][
"name"
]))
if
(
file_exists
(
PATH_TO_ID
.
$_FILES
[
"photo"
][
"name"
]))
{
//echo $_FILES["photo"]["name"] . " existe déjà.";
$message
=
$_FILES
[
"photo"
][
"name"
]
.
" existe déjà."
;
...
...
@@ -54,6 +58,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
// echo "Error: " . $_FILES["photo"]["error"];
$message
=
"Error: "
.
$_FILES
[
"photo"
][
"error"
];
}
header
(
'Content-Type: application/json'
);
echo
json_encode
(
$message
);
}
?>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment