"OdenseTrack" is a school assignment/project from AspIT https://aspit.dfine.net/odensetrack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

upload.class.php 848B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /*
  3. * Handles all uploads
  4. */
  5. class Get {
  6. // Acceptable filetypes
  7. private $filetypes = ['jpeg', 'jpg', 'png', 'svg', 'gif'];
  8. private function __construct() {
  9. }
  10. public static function handleUpload($file = false) {
  11. $errors = [];
  12. $filename = $file['name'];
  13. $size = $file['size'];
  14. $tempname = $file['tempname'];
  15. $type = $file['type'];
  16. $extension = strtolower(end(explode('.', $filename)));
  17. if (!in_array($extension, $this->filetypes)) {
  18. // Error! This file does not have an acceptable filetype
  19. $errors[] = "Filtype ikke accepteret.";
  20. }
  21. if ($size > 5000000) {
  22. $errors[] = "Fil for stor.";
  23. }
  24. if (empty($errors)) {
  25. // Do fileupload
  26. }
  27. }
  28. }