How to Upload and Resize an Image in PHP

Upload and Resize an Image In PHP

Upload and Resize an Image In PHP

In this tutorial, I will teach you how to resize and upload an image in php. .  This method can control the size of the images when uploading it on your website. It also optimize your web pages and lessen the load of time for a faster browsing experience.

Lets begin:

  1. Create the landing page of your project and name it “index.php”.  Copy  this following code and paste it into file.

[php]
<!– extension bootstrap css –>
<link rel=”stylesheet” type=”text/css” href=”css/bootstrap.min.css”>

<h4 align=”center”>Upload and Resize an Image</h4>

<form action=”upload.php” method=”POST” enctype=”multipart/form-data” >
<div class=”container”>
<div class=”row”>
<div class=”col-md-6″>
<div class=”col-md-12″>
<label class=”col-md-3″>Upload Image</label>
<input id=”photo” name=”photo” type=”file”>
</div>
<div class=”col-md-12″>
<label class=”col-md-3″>Choose size</label>
<select name=”size_option”>
<option>Small</option>
<option>Medium</option>
<option>Large</option>
</select>
<input type=”submit” id=”submit” name=”submit” value=”upload”>
</div>

</div>
</div>
<hr/>
<div class=”row”>
<div class=”col-md-12″>
<?php
if (isset($_GET[‘image’])) {

header(‘Location: index.php?image=’.$file_name);
exit;

}
?>

[/php]

For all students who need programmer for your thesis system or anyone who needs a sourcecode in any programming languages.  You can contact me @ :

Email – [email protected]

Mobile No. – 09305235027 – tnt

Dowload the sourcecode here

Leave a Comment