Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

How to Upload and Resize an Image using PHP.

In this post, we are going to learn how to upload and resize an image using PHP. Here we going to use simple PHP code for image upload and resize that image with the help of user-submitted image file data.

When Users upload images to the server then at that time page will not be refresh and after completing image upload it will display an image on the web page without page refresh.

I have made some validation for uploading images. Validation like the image is selected or not, allowed image file formate, size of the image. If this validation passes the image file then after it will upload to the server.

Step 1: Create a new index.php.

Here we need to define form with file input tag and enctype=”multipart/form-data” form Enctype method. It will help us to choose and submit the image file to a PHP script.

Step 2: Resize image PHP code.

Here we are going to define an image upload handling process scripts with thumbnail image creation form an original file.

Here the complete code:

And, also create an uploads name folder for upload and download the image.

Then, RUN these index.php file, you can see the view.

Then, Select the Width, Height and Choose image.

See the result:

Download the Source Code:

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.