I've recently made a new website and I'm using a template. See this image (link):

enter image description here

The file extention is .php. Can anyone explain this?

NOTE: When an image is posted here, stackexchange creates it's own location to store it. If you're right clicking and saving the pic in the question, you'll get a .jpg. But, right click on the picture here.

Here are screenshots of what happens when I try to save it:

Save as


  • Were you able to get the .php and display it as an image, even when dowloaded? (the upload is indeed unrelated). – Vincent Oct 24 '13 at 11:41
  • I don't know what you're asking... Try to save the image in the question now. – BBking Oct 24 '13 at 11:42

A PHP script on the server (which is what the URL causes to be run) returns a response to the browser which contains the header

Content-Type: image/jpeg

so the browser knows that what is returned is a JPEG image and displays it accordingly.

The browser uses the response headers to determine what to do with content. Client operating systems may behave differently — Windows, for example, has a heavy dependence on the filename extension. But if you attempt to save the image from the browser on a Windows system, you may find it's given a .jpg extension because the browser knows it's a JPEG image.

  • Thanks, that's a bit more help. But what would it take to explain why when I go to save the image, it saves it as rotate.php rather than sample-image.jpg ?? Source? – BBking Oct 24 '13 at 11:45
  • Depends on your browser. When I try and save it in Firefox on Windows, it suggests rotate.php.jpg. Answer updated. – Andrew Leach Oct 24 '13 at 11:52
  • I'm using Windows 7, Chrome Version 30.0.1599.101 m. – BBking Oct 24 '13 at 12:02
  • Well there you are. Chrome doesn't add an extension which Windows will understand correctly. – Andrew Leach Oct 24 '13 at 12:20
  • @bbking: in CMS (content management systems) which support templates, the actual image file names and locations may be stored in a database (sometimes even the data for the image is stored in the database as well). They do this so that the scripts for the site only need reference an abstract concept of "sidebar image." Your example, the abstraction is "rotate.php" which presumably looks up the image content and then passes it through to your browser. – horatio Oct 24 '13 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.