Home » File Upload – Auto Resize Compress-Reduce image using PHP

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:  insert Query In Codeigniter Example Tutorial

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:  Vue js Axios HTTP Put Method Example Tutorial From Scratch

<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:  laravel 6 auth

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:  PHP How-to create Dynamic PDF Files using FPDF
  2. Read Also:  PHP Uploading Multiple Files to Amazon S3 Server
  3. Read Also:  PHP Image Compression before Uploading
  4. Read Also:  PHP Image Resize Script Example
  5. Read Also:  Custom Pagination Using WooCommerce REST API
  6. Read Also:  jquery Compress or resize Image File Size before Uploading PHP Code
  7. Read Also:  PHP Google Multi factor authentication Tutorial With Example
  8. Read Also:  how to Install PHP Accelerator Xampp on Windows
  9. Read Also:  PHP Laravel Get Environment Variables Example Tutorial
  10. Read Also:  how to Install PHP Accelerator Xampp on Windows

Leave a Comment

Your email address will not be published. Required fields are marked *