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
7a62bc72
Commit
7a62bc72
authored
Apr 01, 2022
by
Okthane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finitions
parent
b6947caa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
14 deletions
+48
-14
index.php
index.php
+3
-1
removeBackground2.php
removeBackground2.php
+2
-2
script.js
script.js
+39
-8
upload.php
upload.php
+4
-3
No files found.
index.php
View file @
7a62bc72
...
...
@@ -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");
...
...
removeBackground2.php
View file @
7a62bc72
...
...
@@ -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"
);
...
...
script.js
View file @
7a62bc72
...
...
@@ -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;
}
upload.php
View file @
7a62bc72
<?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
);
}
?>
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