Bläddra i källkod

Started to make uploadclass.

tags/rls1
kenn408k 6 år sedan
förälder
incheckning
47292911f1
1 ändrade filer med 39 tillägg och 0 borttagningar
  1. 39
    0
      classes/upload.class.php

+ 39
- 0
classes/upload.class.php Visa fil

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

Laddar…
Avbryt
Spara