A
A
alexandrnevajno12017-11-26 03:58:56
linux
alexandrnevajno1, 2017-11-26 03:58:56

PHP - Is it correct to change the extension to .jpg when uploading an image? Why is this option better?

Hello! I am new to php. I'm parsing someone else's code. Here, when an image is loaded, it is given a new name and the .jpg extension is added to the end of the name. That is, images result in .jpg format (albeit incorrectly).
Tell me - why did the author of the code do this? I can't ask him myself, I don't know who he is.
Is it better than storing images with their format (jpg, bmp, gif...)? And then output - also in their format.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Andrey Barbolin, 2019-09-09
@dronmaxman

DNS is more UDP than TCP traffic.
-A INPUT -p udp --dports 53 -j ACCEPT

P
PatapoIIIka, 2019-09-10
@PatapoIIIka

OUTPUT is not disabled by default.
This line confuses me... Does the DNS server allow itself to send packets to INPUT? Purely in theory, a packet with such a source address can be sent to him. The answer, of course, will go the wrong way, but the DNS server can be spammed with packets with such a source. Someone correct me if I'm wrong.
PS For debug it is better to put Reject. He will at least give information about what happened.
-A INPUT -s 80.1.1.1/32 -j ACCEPT

B
Boris Syomov, 2017-11-26
@alexandrnevajno1

If the .jpg extension is simply added, and it is possible to upload pictures in other formats, then this, of course, is not correct.
If all files are really converted to jpeg, or the download of files in other formats is filtered somewhere, then everything is ok.
Well, yes, the extension has nothing to do with the _file format_, really. This is nothing more than a hint.

S
Stalker_RED, 2017-11-26
@Stalker_RED

bmp weighs much more, and is accordingly slower transmitted. In many cases bmp->jpeg conversion is justified. Gif does not always make sense to convert.
Why he did this is a mystery. In general, there are many tools
for optimizing images , both with and without quality loss.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question