Can I “echo” a .jpg image through php without processing it?

后端 未结 3 747
星月不相逢
星月不相逢 2020-12-20 15:40

Imagine the following:


Now, in image.php:

header(\'content-type:          


        
3条回答
  •  时光说笑
    2020-12-20 15:56

    Sure, using readfile. Don't forget to restrict the allowed image names. Otherwise, you'd be creating a directory traversal vulnerability.

    header('content-type: image/jpeg');
    $img = preg_replace('/[^0-9a-z\._\-]/', '_', $_GET['image']);
    readfile($img);
    

提交回复
热议问题