php-gallery/upload.php

103 lines
3.2 KiB
PHP
Raw Normal View History

2022-07-21 14:53:04 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2022-08-03 16:46:50 +00:00
<title>Lynx Gallery</title>
2022-08-09 20:09:20 +00:00
<!-- Stylesheets -->
2022-07-21 14:53:04 +00:00
<link rel="stylesheet" href="css/master.css">
2022-08-09 20:09:20 +00:00
<link rel="stylesheet" href="css/normalise.css">
<!-- Google Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@600">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Secular+One&display=swap">
2022-08-03 16:46:50 +00:00
<!-- JQuery -->
2022-08-09 20:09:20 +00:00
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous">
</script>
<!-- Sniffle script! -->
<script src="Sniffle/sniffle.js"></script>
<link rel='stylesheet' href='Sniffle/sniffle.css'>
<!-- Flyout script! -->
<script src="Flyout/flyout.js"></script>
<link rel='stylesheet' href='Flyout/flyout.css'>
2022-08-10 13:05:15 +00:00
<!-- Upload Script -->
<script>
$(document).ready(function() {
$("#uploadSubmit").submit(function(event) {
event.preventDefault();
// Check if image avalible
var file = $("#image").val();
if (file != "") {
// Make form
var formData = new FormData();
2022-08-10 13:05:15 +00:00
// Get image
var image_data = $("#image").prop("files")[0];
formData.append("image", image_data);
// Get ALT
var alt = $("#alt").val();
formData.append("alt", alt);
// Get ALT
var submit = $("#submit").val();
formData.append("submit", submit);
2022-08-10 14:55:15 +00:00
// Upload the information
$.ajax({
url: 'app/image/upload_image.php',
type: 'post',
data: formData,
contentType: false,
processData: false,
success: function(response){
$("#sniffle").html(response);
}
});
// Empty values
$("#image").val("");
$("#alt").val("");
$("#submit").val("");
} else {
sniffleAdd('Gwha!', 'Pls provide image', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/file-search.svg');
}
2022-08-10 13:05:15 +00:00
});
});
</script>
2022-07-21 14:53:04 +00:00
</head>
<body>
<?php
include "ui/required.php";
2022-08-03 16:46:50 +00:00
include "ui/nav.php";
2022-07-21 14:53:04 +00:00
2022-07-26 20:51:59 +00:00
// Check if user is logged in
if (!loggedin()) {
2022-08-10 14:55:15 +00:00
echo "
<script>
sniffleAdd('Who are you!', 'You must be loggedin to upload things, sowwy!', 'var(--red)', '".$root_dir."assets/icons/cross.svg');
</script>
";
2022-07-26 20:51:59 +00:00
}
2022-07-21 14:53:04 +00:00
?>
2022-07-26 17:16:17 +00:00
<div class="upload-root default-window">
2022-07-25 15:13:26 +00:00
<h2 class="space-bottom">Upload image</h2>
<p>In this world you have 2 choices, to upload a really cute picture of an animal or fursuit, or something other than those 2 things.</p>
2022-08-10 13:05:15 +00:00
<form id="uploadSubmit" class="flex-down between" method="POST" enctype="multipart/form-data">
2022-08-10 14:55:15 +00:00
<input id="image" class="btn alert-default space-bottom" type="file" placeholder="select image UwU">
<input id="alt" class="btn alert-default space-bottom-large" type="text" placeholder="Description/Alt for image">
<button id="submit" class="btn alert-high" type="submit"><img class="svg" src="assets/icons/upload.svg">Upload Image</button>
2022-07-25 15:13:26 +00:00
</form>
</div>
<?php include "ui/footer.php"; ?>
2022-07-21 14:53:04 +00:00
</body>
</html>