file = $file; $this->file_name = $file['name']; $this->file_size = $file['size']; $this->file_tmp = $file['tmp_name']; $this->file_type = $file['type']; $this->config = $config; $ext = explode('.', $file['name']); $this->file_ext = strtolower(end($ext)); $this->uuid = uniqid(); } private function check_file_size(): bool { if ($this->file_size > $this->config['uploads']['max_file_size']){ $this->errors[] = "File size is too large"; return false; } return true; } private function check_file_extension(): bool { if (!in_array($this->file_ext, $this->extensions)){ $this->errors[] = "Invalid file extension"; return false; } return true; } private function check_file_exists(): bool { if (file_exists($this->upload_dir . $this->file_name)){ $this->errors[] = "File already exists"; return false; } return true; } private function move_file(): bool { if (move_uploaded_file($this->file_tmp, $this->upload_dir . $this->uuid)){ $this->file_path = $this->upload_dir . $this->uuid; return true; } return false; } public function dump_all() { $array = array( "file" => $this->file, "file_name" => $this->file_name, "file_size" => $this->file_size, "file_tmp" => $this->file_tmp, "file_type" => $this->file_type, "file_ext" => $this->file_ext, "file_path" => $this->file_path, "extensions" => $this->extensions, "upload_dir" => $this->upload_dir, "errors" => $this->errors, "ok" => $this->ok, "uuid" => $this->uuid ); } }