Echo/print a jpg-image with php, for safety?

后端 未结 3 430
Happy的楠姐
Happy的楠姐 2021-01-06 02:53

Because of safety (check if user are logged in), I call a php-document when showing images.

...

...&l         


        
3条回答
  •  有刺的猬
    2021-01-06 03:10

    Pascal MARTIN is correct that readfile is essentially the same as echo and file_get_contents. I doubt there is any significant difference in performance, but it's clearer to use readfile.

    As far as only allowing logged in users to see the images, put the images outside of your web-directory. Using readfile, you can grab the file from some other directory. That way, there's no way they could access it, even if they did guess the url.

提交回复
热议问题