Skip to content
Advertisement

Compress image with PHP not reducing image size

I’m trying to compress and upload an image to the server with PHP. The upload are working correctly (without any errors), however the image size remains the same after the upload has completed. Could someone please advise what I could possibly be doing wrong?

Please find the code below:

JavaScript

Advertisement

Answer

If it is working, then you’re immediately overwriting the compressed file with the original, via the move_uploaded_file command, because you’re sending it to the same destination as the compressed file, which was an earlier step.

The move_uploaded_file command is unnecessary in this case – you can remove it

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement