2

I'm making some images with imagejpeg() in PHP and I'm wondering if I have should call my image mysite.com/photos/chicken or mysite.com/photos/chicken.jpg They both seem to work the same. At least for me. Is the .jpg pointless? Unless you want to download the photos and look at them on your computer easily, but I don't.

1
  • 2
    Your users might want to download them. The question is: what is the benefit of not having the extension (other than being hypercool and omitting it)? If there is none, you should just do as everyone else does.
    – kapa
    Mar 12, 2012 at 7:46

3 Answers 3

3

The extension is an additional hint for client programs and users, so it is useful. Sometimes it even matters technically, so I recommend using an extension.

Also see: http://httpd.apache.org/docs/2.0/mod/mod_mime.html#addtype
"The AddType directive maps the given filename extensions onto the specified content type."
This directive is used in many apache configurations.

2

Yes, you are right. If the image is only displayed via the web browser, the file extension is trivial. It's all about the headers being sent.

1

Yes. It is just extensions used to determine the software which will run it as well as visual indicator of what type of file it is. You can save your images using imagejpeg() without an extensions and they will work as you've said just fine:)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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