File Upload – Auto Resize Compress-Reduce image using PHP

File Upload – Auto Resize Compress-Reduce image using PHP

Today, We want to share with you File Upload – Auto Resize Compress-Reduce image using PHP.
In this post we will show you File Upload – Auto Resize Compress-Reduce image using PHP, hear for File Upload – Auto Resize Compress-Reduce image using PHP we will give you demo and example for implement.
In this post, we will learn about File Upload – Auto Resize Compress-Reduce image using PHP with an example.

In this Post,Going to show little bit advance of Auto Resize Compress-Reduce image uploading your server or folder.Means of Resize Image While Uploading with PHP

Read Also:  breadcrumb navxt shortcode

First of all we create on images Folder in Root directory based.nad then home-main.php create a file in this place.It was based on php script to simple Auto Resize Compress-Reduce image upload functionality.

home-main.php

This script resize your uploaded an Image into two 186px and 76px.new Take a look at simple $newwidth and newheight created you have to modify size values.(Image Like as a jpg,png,etc.)

Here in this POST,is a very quick and Fast easy to source code, simple script to do it:

Read Also:  Bootstrap 4 Testimonial Slider Example

<form action="do-mst.php" method="POST" enctype="multipart/form-data">
		<fieldset>
			
			<div class="form-group">
				<label>Apps Title :</label>
				<input class="form-control" name="stitle" placeholder="Apps Title" type="text" value="">
			</div>
			
			<div class="form-group">
				<label>Apps Image(Logo)</label>
				<input type="file" class="file" name="Appslfile" value=""/>
				<br />
				<img src="../images/" height="76px" width="168px" class="img-rounded"/>
				
			</div>
			
		</fieldset>
		<div>
			
		
		</div>
</form>

do-mst.php

query("UPDATE `setting` SET `stvalue`='$stitle' WHERE `stid`=1");
	}
	
	if(move_uploaded_file($_FILES["Appslfile"]["tmp_name"], $target_file)) 
	{
		$stitle=$db->query("UPDATE `setting` SET `stvalue`='$ck_img_name' WHERE `stid`=2");
		
		$orig_image = imagecreatefromjpeg($target_file);
		$temp_img_info = getimagesize($target_file); 
		$width_orig  = $temp_img_info[0]; // current orignal width as found in image file
		$height_orig = $temp_img_info[1]; // current orignal height as found in image file
		$width = 186; // Simple new image user custom width
		$height = 76; // simple new image user custom height
		$des_img_logo = imagecreatetruecolor($width, $height);
		imagecopyresampled($des_img_logo, $orig_image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
		
		imagejpeg($des_img_logo, $target_file, 100);
		
	}
	header("Location: home-main.php");
}
?>

: Example :

Read Also:  PHP Laravel 6 Session-Based Flash Message Example

We hope you get an idea about File Upload – Auto Resize Compress-Reduce image using PHP
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

We hope This Post can help you…….Good Luck!.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  computer dictionary in hindi with Example
  2. Read Also:  Paypal Payment Gateway Integration in PHP Codeigniter Example
  3. Read Also:  Vue.JS Automatically Page Redirection
  4. Read Also:  PHP Image Compression before Uploading
  5. Read Also:  phone number validation in html form
  6. Read Also:  Reset Password Form Free bootstrap Widget Template
  7. Read Also:  Very Simple PHP Script to Upload Image or file from an URL
  8. Read Also:  jquery Compress or resize Image File Size before Uploading PHP Code
  9. Read Also:  vue.js check uncheck all checkboxes Example
  10. Read Also:  PHP Laravel 6 Session-Based Flash Message Example
CLOSEX