Today, We want to share with you PHP Compress Image File Resize while Uploading.
In this post we will show you how to compress image size without losing quality in php, hear for PHP Image Compression, Resize & Optimization we will give you demo and example for implement.
In this post, we will learn about PHP Image Reducing size compression script with an example.

PHP Compress Image File Resize while Uploading

There are the Following The simple About PHP Compress Image File Resize while Uploading Full Information With Example and source code.

As I will cover this Post with live Working example to develop , so the some major files and Directory structures for this example is following below.

  • index.php
  • upload.js
  • upload.php
READ :  AngularJS Datetime format filter in controller

Steps 1: Make Image Upload Form

index.php

This is where I will make a simple HTML form and PHP server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as index.php.

<div class="container">
<h2>Reduce or Compress Image Size While Uploading in PHP</h2>
<form method="post" name="profile_form" id="profile_form" enctype="multipart/form-data" action="upload.php">
<label>Select Images to Upload</label>

<div class="profile_file_upload hidden">
<label> </label>
<img src="uploading.gif" alt="Uploading......" />
</div>
</form>
<div id="uploaded_profile_display"></div>
</div>

Steps 2: Manage Image Upload in jQuery

Include CDN

<a href="http://scripts/jquery.form.js">http://scripts/jquery.form.js</a>
<a href="http://scripts/upload.js">http://scripts/upload.js</a>

Steps 3: Handle Image Upload Form Submit using jQuery

jQuery change event

$(document).ready(function(){
$('#avtar_file').on('change',function(){
$('#profile_form').ajaxForm({
target:'#uploaded_profile_display',
beforeSubmit:function(e){
$('.profile_file_upload').show();
},
success:function(e){
$('.profile_file_upload').hide();
},
error:function(e){
}
}).submit();
});
});

Steps 4: Manage Image Upload

Handle Image Upload as well as your Profile Image Compress

Reduce Image Size While Uploading in PHP – Output

php-and-mysql-upload-with-resize-image
php-and-mysql-upload-with-resize-image
jQuery 15 Powerful Tips and Tricks for Developers and Web Designer

Read :

READ :  JavaScript Display Random Image website

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about How to reduce or compress image size while uploading using PHP.
I would like to have feedback on my Infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.