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
179ce411
Commit
179ce411
authored
May 02, 2022
by
Okthane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit Final Partie Code
parent
39631691
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
116 additions
and
124 deletions
+116
-124
byebye.html
byebye.html
+1
-1
index.php
index.php
+8
-7
removeBackground2.php
removeBackground2.php
+3
-3
script.js
script.js
+98
-105
upload.php
upload.php
+4
-6
web_server.php
web_server.php
+2
-2
No files found.
byebye.html
View file @
179ce411
index.php
View file @
179ce411
...
...
@@ -16,7 +16,7 @@
<script
src=
"https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"
></script>
<script
src=
"https://cdn.jsdelivr.net/npm/@tensorflow-models/blazeface"
></script>
<script
src=
"jquery.js"
></script>
<script
src=
"script.js"
></script>
<title>
Formulaire d'upload de fichiers
</title>
<!-- API TenserFlow -->
</head>
...
...
@@ -64,9 +64,9 @@
</div>
<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-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/png)
<span></span></li>
<li
id=
"li-taille"
class=
"list-group-item list-group-item-secondary"
>
Poids (
<
1
Mo
)
<
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"
>
...
...
@@ -77,7 +77,7 @@
<div
class =
"row d-flex justify-content-center"
>
<div
class=
"div-form"
>
<form
id =
"form"
action=
""
method=
"
"
enctype=
"multipart/form-data"
>
<form
id =
"form"
action=
""
method=
"POST
"
enctype=
"multipart/form-data"
>
<!-- <label for="fileUpload">Fichier:</label> -->
<div
class=
"div-btn-form"
>
<input
type=
"file"
name=
"photo"
id=
"fileUpload"
required=
"required"
class=
"btn-form"
accept=
"image/png, image/jpeg"
>
...
...
@@ -92,7 +92,7 @@
const
inpFile
=
document
.
getElementById
(
"fileUpload"
);
const
previewImage
=
document
.
getElementById
(
"img-ID"
);
const
file
=
inpFile
.
files
[
0
];
console
.
log
(
"ok"
);
console
.
log
(
file
);
if
(
file
){
const
reader
=
new
FileReader
();
console
.
log
(
"ok"
);
...
...
@@ -105,7 +105,7 @@
}
inpFile
.
addEventListener
(
"change"
,
function
(){
const
file
=
inpFile
.
files
[
0
];
console
.
log
(
"ok"
);
console
.
log
(
file
);
if
(
file
){
const
reader
=
new
FileReader
();
console
.
log
(
"ok"
);
...
...
@@ -125,6 +125,7 @@
// defaultBtn.click();
// }
</script>
<script
src=
"script.js"
></script>
</div>
</div>
...
...
removeBackground2.php
View file @
179ce411
<?php
// phpinfo();
define
(
'PATH'
,
"img_bg"
);
define
(
'KEY'
,
'n6CkFXudANRCubRKMKG5hjNa'
);
define
(
'PATH'
,
'img_bg'
);
define
(
'KEY'
,
'n6CkFXudANRCubRKMKG5hjNa'
);
require_once
"vendor/autoload.php"
;
...
...
@@ -21,7 +21,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
$ext
=
pathinfo
(
$filename
,
PATHINFO_EXTENSION
);
if
(
array_key_exists
(
$ext
,
$allowed
))
{
$client
=
new
GuzzleHttp\Client
([
"verify"
=>
false
]);
$client
=
new
GuzzleHttp\Client
([
"verify"
=>
false
]);
$res
=
$client
->
post
(
'https://api.remove.bg/v1.0/removebg'
,
[
'multipart'
=>
[
[
...
...
script.js
View file @
179ce411
...
...
@@ -27,6 +27,7 @@ var errorRemoveBackGround = true;
var
unSeulVisage
=
false
;
var
format_correct
=
false
;
const
id_li_OneFace
=
"li-oneface"
;
var
li_OneFace
;
const
id_li_format
=
"li-format"
;
var
li_format
;
const
id_li_taille
=
"li-taille"
;
var
li_taille
;
...
...
@@ -35,9 +36,6 @@ const id_li_taille = "li-taille"; var li_taille;
$
(
document
).
ready
(
function
(){
// console.log(inputFileUpload.val());
console
.
log
(
getParameter
(
window
.
location
.
href
));
//Variables des éléments du DOM.
inputFileUpload
=
$
(
"#"
+
idFileUpload
);
btnCustomFileUpload
=
$
(
"#"
+
idCustomFileUpload
);
...
...
@@ -52,58 +50,6 @@ $(document).ready(function(){
li_taille
=
$
(
"#"
+
id_li_taille
);
//Si l'on change la photo,
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
)
{
if
(
valide
==
false
)
{
event
.
preventDefault
();
var
formData
=
new
FormData
(
this
);
console
.
log
(
inputFileUpload
.
attr
(
'filename'
));
//Requête pour vérifier l'intégrité du fichier, ses dimensions
$
.
ajax
({
url
:
URL_CHECK_ID
,
method
:
'POST'
,
enctype
:
'multipart/form-data'
,
data
:
formData
,
cache
:
false
,
dataType
:
"json"
,
contentType
:
false
,
processData
:
false
})
.
fail
(
function
(
error
){
Console
.
empty
();
alert
(
"La requête s'est terminée en échec. Infos : "
+
JSON
.
stringify
(
error
));
})
.
done
(
function
(
data
){
errorFormat
=
data
[
'error'
];
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
);
}
})}
});
//Récupération des données concernant l'étudiant & proposition des différentes addresses mail.
studentId
=
getParameter
(
window
.
location
.
href
);
...
...
@@ -125,7 +71,9 @@ $(document).ready(function(){
let
mailCalcule
=
data
[
"mailCalcule"
];
let
mailsPossibles
=
data
[
"mailsPossibles"
];
if
(
mailsPossibles
.
length
!=
0
){
if
(
mailsPossibles
.
length
!=
0
)
{
$
(
"body"
).
append
(
`<div class = "container grayarea">
<h2 class="text-center">Choix de l'adresse électronique</h2>
...
...
@@ -136,7 +84,7 @@ $(document).ready(function(){
</div>
</div>`
);
let
required
=
0
;
mailsPossibles
.
forEach
(
element
=>
{
$
(
'#choix-email'
).
append
(
`<input type="radio" id="
${
element
}
" name="mail" value="
${
element
}
" required>
...
...
@@ -148,7 +96,8 @@ $(document).ready(function(){
`<input type="submit" id="valide-mail" value="Ok c'est bon !" class="btn btn-secondary" style="background-color:#00b8de">`
);
}
else
{
else
{
$
(
"body"
).
append
(
`
<div class = "container grayarea text-center">
<h3>Votre adresse électronique sera
${
mailCalcule
}
, vous recevrez votre mot de passe dans les 24 heures.</h3>
...
...
@@ -164,22 +113,65 @@ $(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
;
//====EVENEMENTS========================================================
//Si l'on change la photo,
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 "
);
});
// 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
();}
//Requête pour les vérifications de sécurité & de format
$
(
"#form"
).
on
(
"submit"
,
function
(
event
)
{
if
(
valide
==
false
)
{
event
.
preventDefault
();
const
file
=
inpFile
.
files
[
0
];
const
extension
=
file
.
name
.
substring
(
file
.
name
.
lastIndexOf
(
'.'
)
+
1
,
file
.
name
.
length
)
||
file
.
name
;
// La photo se nomme avec l'ID.
const
formData
=
new
FormData
();
formData
.
set
(
"photo"
,
file
,
studentId
+
"."
+
extension
);
//Requête pour vérifier l'intégrité du fichier, ses dimensions
$
.
ajax
({
url
:
URL_CHECK_ID
,
method
:
'POST'
,
enctype
:
'multipart/form-data'
,
data
:
formData
,
cache
:
false
,
dataType
:
"json"
,
contentType
:
false
,
processData
:
false
})
.
fail
(
function
(
error
){
Console
.
empty
();
alert
(
"La requête s'est terminée en échec. Infos : "
+
JSON
.
stringify
(
error
));
})
.
done
(
function
(
data
){
errorFormat
=
data
[
'error'
];
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
);
}
})}
});
});
...
...
@@ -194,10 +186,11 @@ function sendMail(){
console
.
log
(
"unSeulVisage: "
+
unSeulVisage
+
"
\n
format_correct: "
+
format_correct
);
if
(
unSeulVisage
&&
format_correct
){
$
.
ajax
({
url
:
URL_CHOOSE_MAIL
,
method
:
'POST'
,
data
:
'mail='
+
mail
,
dataType
:
"json"
url
:
URL_CHOOSE_MAIL
,
method
:
'POST'
,
data
:
'mail='
+
mail
,
dataType
:
"json"
});
window
.
open
(
URL_END
,
'_self'
);
}
...
...
@@ -210,17 +203,15 @@ function sendMail(){
async
function
photoDetourage
(
formData
){
await
findFaces
(
ID
);
if
(
unSeulVisage
){
// if (true){
$
.
ajax
({
//url de la requête
url
:
URL_DETOURAGE
,
method
:
'POST'
,
enctype
:
'multipart/form-data'
,
data
:
formData
,
url
:
URL_DETOURAGE
,
method
:
'POST'
,
enctype
:
'multipart/form-data'
,
data
:
formData
,
cache
:
false
,
dataType
:
"json"
,
cache
:
false
,
dataType
:
"json"
,
contentType
:
false
,
processData
:
false
})
...
...
@@ -230,7 +221,6 @@ async function photoDetourage(formData){
ImgBG
.
attr
(
'src'
,
data
[
'src'
]);
})
}
}
async
function
findFaces
(
idImage
)
{
...
...
@@ -253,13 +243,17 @@ async function findFaces(idImage) {
// // Render a rectangle over each detected face.
// ctx.fillRect(start[0], start[1], size[0], size[1]);
// }
$
(
"#"
+
idStatut
).
empty
();
$
(
"#"
+
idStatut
).
append
(
predictions
.
length
+
" face(s) found!"
);
if
(
predictions
.
length
==
1
){
$
(
"#"
+
idStatut
).
empty
();
$
(
"#"
+
idStatut
).
append
(
predictions
.
length
+
" face(s) found!"
);
if
(
predictions
.
length
==
1
)
{
li_OneFace
.
removeClass
(
"list-group-item-secondary list-group-item-danger"
).
addClass
(
"list-group-item-success"
);
unSeulVisage
=
true
;
}
else
{
li_OneFace
.
removeClass
(
"list-group-item-secondary list-group-item-success"
).
addClass
(
"list-group-item-danger"
);}
else
{
li_OneFace
.
removeClass
(
"list-group-item-secondary list-group-item-success"
).
addClass
(
"list-group-item-danger"
);
}
}
else
{
li_OneFace
.
removeClass
(
"list-group-item-secondary list-group-item-success"
).
addClass
(
"list-group-item-danger"
);
...
...
@@ -267,7 +261,6 @@ async function findFaces(idImage) {
btnSubmit
.
prop
(
'disabled'
,
false
);
btnCustomFileUpload
.
prop
(
'disabled'
,
false
);
$
(
"body"
).
css
(
"cursor"
,
""
);
// return predictions.length;
}
function
getParameter
(
url
){
...
...
@@ -300,7 +293,7 @@ function get_base64(src){
var string = src;
var k = 0;
var base_64;
while (string.slice(k,k+7)
!="base64," &&
k<100)
while (string.slice(k,k+7)
!= "base64," &&
k<100)
{
k=k+1;
}
...
...
upload.php
View file @
179ce411
<?php
//dossier temporaitre pour les images
define
(
'PATH_TO_TEMP'
,
"temp"
);
define
(
'PATH_TO_TEMP'
,
"temp"
);
// 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
// Format de la réponse
if
(
isset
(
$_FILES
[
"photo"
])
&&
$_FILES
[
"photo"
][
"error"
]
==
0
)
{
$allowed
=
array
(
...
...
web_server.php
View file @
179ce411
...
...
@@ -7,8 +7,8 @@ if($_SERVER["REQUEST_METHOD"]=="POST"){
"prenom"
=>
"jean-patrick"
,
"nom"
=>
"doe.remifa.sollasi"
,
"mailCalcule"
=>
"patrick.doe.remifa.sollasi@ext.imt-nord-europe.fr"
,
//
"mailsPossibles" => array()
"mailsPossibles"
=>
array
(
"jean-patrick.doe@ext.imt-nord-europe.fr"
,
"jean.doe@ext.imt-nord-europe.fr"
,
"patrick.doe@ext.imt-nord-europe.fr"
,
"jean.remifa.sollasi@ext.imt-nord-europe.fr"
,
"jp.doeremifasollasi@ext.imt-nord-europe.fr"
)
"mailsPossibles"
=>
array
()
//
"mailsPossibles"=>array("jean-patrick.doe@ext.imt-nord-europe.fr","jean.doe@ext.imt-nord-europe.fr","patrick.doe@ext.imt-nord-europe.fr","jean.remifa.sollasi@ext.imt-nord-europe.fr","jp.doeremifasollasi@ext.imt-nord-europe.fr")
);
echo
json_encode
(
$data
);
...
...
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