I have a web page with some pictures. Most of them are in .jpg format, but I also have some in .png format. I need to make a universal link which could let me display both format pictures. At the moment my code looks like this:
Simple. The file extension (.jpg/.png/.whatever) should be a part of the actual filename in $picture->pictureName (yourimage.jpg/yourimage.png, etc). I've never seen anybody store files without the extension. Why would you do that? If you save files normally with the extension, then it doesn't matter. You'd just
Thank you for a quick reply. The problem is that $picture->pictureName is coming from the database. In the database these picture names are stored without any extension as I use these picture names for some another purposes as well. Do you know if there are any possible constructions like ".*" or "'.jpg' || '.png'"?
Do you know if there are any possible constructions like ".*" or "'.jpg' || '.png'"?
No. Problem is php doesn't know whether the file on the filesystem with .png/.jpg exists. So you'd have to wrote code to first check wither filename.jpg exists, if not, use filename.png. Quite wasteful and intensive, when there is a much simpler solution.
Store them with the file extension (and store the base filename in another column without extension). Or have another column to store the file extension.
then it will all be dynamic. Personally I'd store it with the extension, and use a separate column to store the base filename to use however else you're using it.