Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'init.php';
- if (!logged_in()) {
- header('location: header.php');
- exit();
- }
- include 'template/header.php';
- ?>
- <h3>Upload image</h3>
- <?php
- if (isset($_FILES['image'], $_POST['album_id'])) {
- $image_name = $_FILES['image']['name'];
- $image_size = $_FILES['image']['size'];
- $image_temp = $_FILES['image']['tmp_name'];
- $allowed_ext = array('jpeg', 'jpg', 'png', 'gif');
- $tmp = explode('.', $image_name);
- $image_ext = strtolower(end($tmp));
- $album_id = $_POST['album_id'];
- $errors = array();
- if (empty($image_name) || empty($album_id)) {
- $errors[] = 'Don\t modify the HTML code faggot.';
- } else {
- if (in_array($image_ext, $allowed_ext) === false) {
- $errors[] = 'File extension not allowed.';
- }
- if ($image_size > 2097152) {
- $errors[] = 'Maximum file size is 2mb.';
- }
- if (album_check($album_id) === false) {
- $errors[] = 'Don\'t modify the HTML code faggot.';
- }
- if (!empty($errors)) {
- echo 'There are errors';
- } else {
- echo 'There are no errors';
- }
- }
- }
- $albums = get_albums();
- if (empty($albums)) {
- echo '<p>You don\'t have any albums. Create one by clicking <a href="create_album.php">here</a>!</p>';
- } else {
- ?>
- <form action="" method="post" enctype="multipart/form-data">
- <p>Choose a file: <br /><input type="file" name="image" /></p>
- <p>
- Choose an album:<br />
- <select id="choose_album">
- <?php
- foreach($albums as $album) {
- echo '<option value="', $album['id'] ,'">', $album['name'] ,'</option>';
- }
- ?>
- </select>
- </p>
- <p><input type="submit" value="Upload" /></p>
- </form>
- <?php
- }
- include 'template/footer.php';
- ?>
Add Comment
Please, Sign In to add comment