-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuploadImage.php
31 lines (25 loc) · 935 Bytes
/
uploadImage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
$title = "Upload new image";
$content = '<form action="" method="post" enctype="multipart/form-data">
<label for="file">Filename: </label>
<input type="file" name="file" id="file"><br/>
<input type="submit" name="submit" value="submit">
</form>';
//Check if filetype is a valid format
if (isset($_POST["submit"])) {
$fileType = $_FILES["file"]["type"];
if (($fileType == "image/gif") ||
($fileType == "image/jpeg") ||
($fileType == "image/jpg") ||
($fileType == "image/png")) {
//Check if file exists
if (file_exists("Images/Coffee/" . $_FILES["file"]["name"])) {
echo "File already exists";
} else {
move_uploaded_file($_FILES["file"]["tmp_name"], "Images/Coffee/" . $_FILES["file"]["name"]);
echo "Uploaded in " . "Images/Coffee/" . $_FILES["file"]["name"];
}
}
}
include './Template.php';
?>