samedi 30 avril 2016

How to get picture extension when it's from my database

Hello everyone My project is to make a website where people can sign up and log in and then they are able to lend their car or borrow one from another user. I made a function to upload picture to the database and also one to show pictures from the database but it only work for the jpeg extension and I would like to not make ~15487521 conditions to make it work for any extension( more like ~5 but all these conditions dont make the code really clean...) So I would like to know if you guys could help me to find a solution to retrieve the extension of a picture from a database.

I'm using '<img src="data:image/jpg;base64,'.base64_encode($ticket['image']).'" />'; And my idea is to replace "jpg" by a string variable... I think I should use pathinfo(X,PATHINFO_EXTENSION) but I dont know what to put in "X"

Thank you

EDIT

Ok so I just figured out that I can change the extension in "data:image/jpg" for gif, png, etc. as I wish and it still works.( I really do not understand why ) So I think that my problem does not really exist. Lol. Thank you guys for your help and I hope that this post will help other people ! :)




Aucun commentaire:

Enregistrer un commentaire