chrizonline
chrizonline

Reputation: 4979

get image and display through php script

i notice some webpage display images using php scripts. how do i do that and wats the benefit? forexample: http://static.ak.fbcdn.net/rsrc.php/yp/r/kk8dc2UJYJ4.png

Upvotes: 1

Views: 906

Answers (1)

ThiefMaster
ThiefMaster

Reputation: 318468

Why showing images through PHP might be useful:

  • Being able to control/restrict access to the images in a complex way (e.g. not just by http auth, ip, referer etc.).
  • Being able to dynamically modify images before they are displayed (watermarks for example)

How you do that:

Send the appropriate header for whatver image type (e.g. header('image/png');) you want to show and then output the raw image data, e.g. using readfile()

Upvotes: 4

Related Questions