It is a very easy way to uploading image in php folder with particular location and allowed minimum size of image and also with particular extension. 1. upload.php 2. create upload folder in root directory /// upload.php if(isset($_POST['submit'])) { $fileName = $_FILES['file']['name']; $targetDir = 'upload/'; $targetDir = $targetDir . basename($fileName); $fileExtension = strtolower(pathinfo($targetDir, PATHINFO_EXTENSION)); $fileSize = $_FILES['file']['size']; try { if($fileExtension != 'jpg' && $fileExtension != 'jpeg' && $fileExtension != 'png') { echo "sorry file format not allowed"; } if($fileSize > 1000000) { echo "file size not allowed more ...