<?php /*Make sure user is logged in*/ session_start(); include '../phpfunction.php'; if ($_SESSION['user'] == 0) { header("Location: ../index.php"); } $target_dir = "./"; $limit_mb = find_file_upload_limit(); if (count($_FILES) == 0) { die("No files received! You may have exceeded the file upload limit, which appears to be {$limit_mb} MB"); } if (isset($_POST["submit"])) { $basename = str_replace(' ', '', basename($_FILES["fileToUpload"]["name"])); $target_file = $target_dir . $basename; if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { $mapdesc = $_POST["description"]; $mapordering = $_POST['ordering']; $query = "INSERT INTO `maps`(`url`, `desc`, `ordering`) VALUES (?, ?, ?)"; $stmt = $writedb->prepare($query); $stmt->bind_param("ssi", $basename, $mapdesc, $mapordering); if (!$stmt->execute()) { unlink($target_file); die("Operation failed: " . $stmt->error); } header("Location: manage.php"); } else { die("Sorry, there was an error uploading your file. You either need to adjust your permissions or you may have exceeded the file upload limit, which appears to be {$limit_mb} MB"); } } else {
} else { die("Couldn't load maps!"); } ?> </div> <div id='preview-wrapper'> <h3>File Preview</h3> <div id='preview'> </div> </div> <br class='clr'> <?php $upload_limit = find_file_upload_limit(); ?> <div id='fileuploader'> <form action="upload.php" method="post" enctype="multipart/form-data"> <h2>Upload New Map</h2> <input type="file" name="fileToUpload" id="fileToUpload" size="70" data-uploadlimit="<?php echo $upload_limit * 1024 * 1024; ?> "><br> <label for="description">Description: </label> <input type="text" name="description" id="description"/><br> <label for="ordering">Sorting Order: </label> <input type="text" name="ordering" id="ordering"/><br> <div id='file-warning'></div> <input type="submit" value="Upload Map" name="submit">