image upload in php

image upload in php first of all inside the form tag you needs to create the input type file and for form tag you need to add enctype=”multipart/form-data”.check below form code.

Final Output

php upload file to server

when user click on submit button we need to pass the file value to our php script. in our example we are added some validations.

  • Check for upload file is image or not.
  • Check if file is already exists or not.
  • Check file size.
  • Checking format of images.

check below for complete source code. you just needs to create one directory “uploads” inside our project run. if all the validations are pass then we get success message and uploaded image is inside the our created directory.