Note: enctype=”multipart/form-data” is compulsory for image upload precess via post method in form.Īfter the form submission, the file data is submitted to the upload.php file for further processing.
So, now I am show you how to compress image before upload using PHP.Ĭreate a PHP form with an input field and submit button. Here is a link to a function I wrote for resizing an image to any arbitrary size. In this case, compress images before upload to optimize the image. You can resize an image using PHPs native GD library. Generally, the user does not optimize the image when uploading through the website.
After copying the image it will resize the image with a new name in the server. Image compression is very helpful to reduce the size of the image. First we are going to make an upload page and this upload page will send the image to the server.