V
V
vladislav9972020-05-18 15:26:36
PHP
vladislav997, 2020-05-18 15:26:36

How to display an image with a specific name but an unknown extension (jpg/png)?

Tell me how to display an image with a specific name, but an unknown extension (jpg/png)? At the moment I only output jpg like this:

echo '<img src="users/'.$user->folder.'/cover_user.jpg">';

those. the file name is always: cover_user, but the extension can be both jpg and png, how to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
John Didact, 2020-05-18
@vladislav997

Well, actually, cover_user.jpgthat's the name. A users/dirname/cover_user.jpgis the relative path to the file. As the fanatic said, store the image in a single type or without .расширениеit, just give the corresponding mime in the title.

F
FanatPHP, 2020-05-18
@FanatPHP

No need to ask how to put the crutch. By doing this, you offend the feelings of the respondent.
You have to do it right now. or convert all pictures to a single format, or save without extension.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question