+
+ if (!empty($_FILES['customFile']))
+ {
+ $cwd = getcwd();
+ $a = split($cwd,'/');
+ $a[sizeof($a) - 1] = NULL;
+ $cwd = glue($a,'/');
+ $target_dir = "$cwd/img/";
+ $target_file = "/$target_dir/wallpaper.jpg";
+ $uploadOk = 1;
+ $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
+ $check = getimagesize($_FILES["customFile"]["tmp_name"]);
+ $errs = [];
+
+ if($check == false)
+ {
+ $errs[] = "File is not an image.";
+ $uploadOk = 0;
+ }
+ else if ($_FILES["customFile"]["size"] > 500000) {
+ $errs[] = "File is too large.";
+ $uploadOk = 0;
+ }
+ elseif($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
+ && $imageFileType != "gif" )
+ {
+ $errs[] = "Only JPG, JPEG, PNG & GIF files are allowed.";
+ $uploadOk = 0;
+ }
+ if ($uploadOk != 0) {
+ if (file_exists($target_file))
+ unlink($target_file);
+ move_uploaded_file($_FILES["customFile"]["tmp_name"], $target_file);
+ Message::Success("Updloaded file: $target_file");
+ }
+ else Message::Fail($errs);
+ }
+