예제 #1
0
 public static function upload(string $path, string $postName = "images", $thumbWidth = 300, $thumbHeight = 300)
 {
     $path = FileSystem::getRealPath($path);
     $response = [];
     if (isset($_FILES[$postName])) {
         foreach ($_FILES[$postName]["error"] as $key => $error) {
             if ($error == UPLOAD_ERR_OK) {
                 $tmp_name = $_FILES[$postName]["tmp_name"][$key];
                 $name = Etc::sanitize($_FILES[$postName]["name"][$key]);
                 if (move_uploaded_file($tmp_name, "{$path}/{$name}")) {
                     $image = new Image("{$path}/{$name}");
                     $response[] = ["thumb" => $image->src($thumbWidth, $thumbHeight), "file" => $name];
                 }
             }
         }
     }
     return $response;
 }
예제 #2
0
function image(string $path, float $width = null, float $height = null)
{
    $image = new Image($path);
    return $image->src($width, $height);
}