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
ad2dfd5d
Commit
ad2dfd5d
authored
3 years ago
by
BOUAZIZ Nassim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
page upload minimaliste
parent
0c71da51
master
No related merge requests found
Pipeline
#1415
canceled with stages
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
upload.php
upload.php
+37
-0
No files found.
upload.php
0 → 100644
View file @
ad2dfd5d
<?php
// Vérifier si le formulaire a été soumis
if
(
$_SERVER
[
"REQUEST_METHOD"
]
==
"POST"
){
// Vérifie si le fichier a été uploadé sans erreur.
if
(
isset
(
$_FILES
[
"photo"
])
&&
$_FILES
[
"photo"
][
"error"
]
==
0
){
$allowed
=
array
(
"jpg"
=>
"image/jpg"
,
"jpeg"
=>
"image/jpeg"
,
"gif"
=>
"image/gif"
,
"png"
=>
"image/png"
);
$filename
=
$_FILES
[
"photo"
][
"name"
];
$filetype
=
$_FILES
[
"photo"
][
"type"
];
$filesize
=
$_FILES
[
"photo"
][
"size"
];
// Vérifie l'extension du fichier
$ext
=
pathinfo
(
$filename
,
PATHINFO_EXTENSION
);
if
(
!
array_key_exists
(
$ext
,
$allowed
))
die
(
"Erreur : Veuillez sélectionner un format de fichier valide."
);
// Vérifie la taille du fichier - 5Mo maximum
$maxsize
=
5
*
1024
*
1024
;
if
(
$filesize
>
$maxsize
)
die
(
"Error: La taille du fichier est supérieure à la limite autorisée."
);
// Vérifie le type MIME du fichier
if
(
in_array
(
$filetype
,
$allowed
)){
// Vérifie si le fichier existe avant de le télécharger.
if
(
file_exists
(
"upload/"
.
$_FILES
[
"photo"
][
"name"
])){
echo
$_FILES
[
"photo"
][
"name"
]
.
" existe déjà."
;
}
else
{
move_uploaded_file
(
$_FILES
[
"photo"
][
"tmp_name"
],
"C:/wamp64/www/PROJET/upload/"
.
$_FILES
[
"photo"
][
"name"
]);
echo
"Votre fichier a été téléchargé avec succès."
;
echo
(
"<br></br>"
);
echo
"taille de la photo : "
.
$_FILES
[
"photo"
][
"size"
]
.
" octets"
;
}
}
else
{
echo
"Error: Il y a eu un problème de téléchargement de votre fichier. Veuillez réessayer."
;
}
}
else
{
echo
"Error: "
.
$_FILES
[
"photo"
][
"error"
];
}
}
?>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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