Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I Return "500" or "404" if a Requested Image is not Found?

I work with code written by other people, occasionally I am left somewhat confused and at these times Stack Overflow saves me. Please, save me again.

Our site allows people to upload images and later embed them within text in our site like so:

<img src="http://site.com/image_script.php?p=some_image_identifier"/>

My question is:

If the identifier, "p", does not lead us to an image should the server return "500" or "404"?

I would have thought it should be "404", but that's not what is happening right now.

like image 955
Michael Robinson Avatar asked Dec 01 '22 05:12

Michael Robinson


1 Answers

500 is an error in fulfilling the request. So if the request processed fine and the file is not found, you should return a 404.

like image 183
Ólafur Waage Avatar answered Dec 04 '22 10:12

Ólafur Waage