47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
include 'include/db.php';
|
|
include 'include/templates.php';
|
|
|
|
loggedInCheck();
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
$path_parts = pathinfo($_FILES["fileToUpload"]["name"]);
|
|
$location = "img/" . bin2hex(random_bytes(16)) . "-" . time() . "." . $path_parts['extension'];
|
|
$uploadValid = 1;
|
|
|
|
if(@is_array(getimagesize($_FILES["fileToUpload"]["tmp_name"])) == false){
|
|
$uploadValid = 0;
|
|
}
|
|
|
|
if($_FILES['userfile']['size'] > 300000000){
|
|
$uploadValid = 0;
|
|
}
|
|
|
|
if(ctype_alnum(str_replace("_", "",str_replace(",","",$_POST["tags"]))) == false){
|
|
$uploadValid = 0;
|
|
}
|
|
|
|
if($uploadValid == 0){
|
|
showHeader();
|
|
echo '<h3>An error has occured, please try again.</h3>';
|
|
echo $footer;
|
|
die();
|
|
} else {
|
|
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $location);
|
|
|
|
addImage($location, tokenToUuid($_COOKIE["meowboardSession"]), $_POST["tags"]);
|
|
showHeader();
|
|
echo '<h3>File uploaded!</h3>';
|
|
echo $footer;
|
|
exit();
|
|
}
|
|
|
|
} else {
|
|
showHeader();
|
|
echo '<h3>Upload</h3><form action="upload.php" method="post" enctype="multipart/form-data">
|
|
<div class="upload">Upload <input type="file" name="fileToUpload" id="fileToUpload"> <icon>⇑</icon></div>
|
|
<label for="tags">Tags</label><br/><input type="text" id="tags" name="tags">
|
|
<br/><button>submit</button>
|
|
</form>';
|
|
echo $footer;
|
|
}
|
|
?>
|