Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use foundationphp\UploadFile;
- session_start();
- require_once 'src/foundationphp/UploadFile.php';
- if (!isset($_SESSION['maxfiles'])) {
- $_SESSION['maxfiles'] = ini_get('max_file_uploads');
- $_SESSION['postmax'] = UploadFile::convertToBytes(ini_get('post_max_size'));
- $_SESSION['displaymax'] = UploadFile::convertFromBytes($_SESSION['postmax']);
- }
- $max = 51200 * 1024;
- $result = array();
- if (isset($_POST['upload'])) {
- $destination = __DIR__ . '/uploaded/';
- try {
- $upload = new UploadFile($destination);
- $upload -> setMaxSize($max);
- $upload -> allowAllTypes();
- $upload -> upload();
- $result = $upload -> getMessages();
- } catch (Exception $e) {
- $result[] = $e -> getMessage();
- }
- }
- $error = error_get_last();
- ?>
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Inleveren</title>
- <link href="styles/form.css" rel="stylesheet" type="text/css">
- </head>
- <body>
- <h1>Bestanden uploaden</h1>
- <?php if ($result || $error) {
- ?>
- <ul class="result">
- <?php
- if ($error) {
- echo "<li>{$error['message']}</li>";
- }
- if ($result) {
- foreach ($result as $message) {
- echo "<li>$message</li>";
- }
- }
- ?>
- </ul>
- <?php } ?>
- <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
- <p>
- <label for="username">Naam:</label>
- <input type="text" name="name" id="" />
- <br />
- <label for="class">Klas:</label>
- <select name="class">
- <option value="h4a">h4a</option>
- <option value="h4b">h4b</option>
- <option value="h4c">h4c</option>
- <option value="h5a">h5a</option>
- <option value="h5b">h5b</option>
- <option value="h5c">h5c</option>
- </select>
- <br />
- <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max; ?>">
- <label for="filename">Selecteer bestand:</label>
- <input type="file" name="filename[]" id="filename" multiple
- data-maxfiles="<?php echo $_SESSION['maxfiles']; ?>"
- data-postmax="<?php echo $_SESSION['postmax']; ?>"
- data-displaymax="<?php echo $_SESSION['displaymax']; ?>">
- </p>
- <ul>
- <li>
- Er kunnen <?php echo $_SESSION['maxfiles']; ?> bestanden tegelijkertijd worden geupload.
- </li>
- <li>
- Elk bestand mag niet groter zijn dan <?php echo UploadFile::convertFromBytes($max); ?>.
- </li>
- <li>
- Samen mag het niet meer dan <?php echo $_SESSION['displaymax']; ?> zijn.
- </li>
- </ul>
- <p>
- <input type="submit" name="upload" value="Inleveren">
- </p>
- </form>
- <script src="js/checkmultiple.js"></script>
- <?php
- echo '<pre>';
- print_r($_POST);
- echo '</pre>';
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement