| 123456789101112131415161718192021222324252627 |
- <?php
- $user = User::get($id);
- if(!$user) throw new Exception("User not found.");
- switch($type) {
- case "id-document":
- $file_type = UserFile::TYPE_ID;
- break;
- case "photo":
- $file_type = UserFile::TYPE_PHOTO;
- break;
- }
- $nvp = [
- "user_id" => $id,
- "type" => $file_type
- ];
- $file = UserFile::queryOne($nvp);
- if(!$file) HTTP::redirect("/img/blank.png");
- $path = $user->getDirectory() . "/" . $file->id . ".jpg";
- if(!file_exists($path)) HTTP::redirect("/img/blank.png");
- header("Content-Type: image/jpeg");
- readfile($path);
|