Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_SESSION['level']) > 0) {
- echo '
- <form action="upload.php" method="POST" enctype="multipart/form-data">
- <input style="color: #A30000; margin-bottom: 10px;" type="text" name="title" placeholder="Post Title" required/><br/>
- <input style="color: #A30000; margin-bottom: 10px;" type="date" name="date" required/><br />
- <span style="font-weight: bold; font-family: arial;">Image:</span><br/>
- <input style="margin-bottom: 10px;" type="file" name="fileToUpload" id="fileToUpload"/><br />
- <textarea style="margin-bottom: 10px; color: #A30000; width: 320px; height: 200px;" type="text" name="summary" placeholder="Summary" required></textarea><br />
- <input value="Create Post" type="submit"/>
- </form>
- ';
- } else {
- echo 'You are not an admin so can not view this part of the page.';
- }
- /* upload.php */
- $target_dir = "uploads/";
- $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
- $uploadOk = 1;
- $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
- // Check if image file is an actual or fake image
- if(isset($_POST["submit"])) {
- $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
- if($check !== false) {
- $uploadOk = 1;
- } else {
- $uploadOk = 0;
- }
- }
- // Check if file already exists
- if (file_exists($target_file)) {
- echo "Sorry, file already exists.";
- $uploadOk = 0;
- }
- // Allow certain file formats
- if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" ) {
- echo "Sorry, only JPG, JPEG, & PNG files are allowed.";
- $uploadOk = 0;
- }
- // Check file width / height
- // Need to figure out how to only allow images that are 1920 x 1080 as well as 1280 x 720
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement