50000000) { // 50 MB Maximum File size is allowed echo "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if($imageFileType == "jpg" || $imageFileType == "jpeg") { $uploadOk = 1; } else { echo "Sorry, only JPG / JPEG Format is allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo " Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { //echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded."; $filePath = "./images/".htmlspecialchars($tempJpgFileName); $compressedFilePath = "./compressed_images/".$tempJpgFileName; compress($filePath, $compressedFilePath, $compression); echo "
| Original File | Compressed File |
|---|---|
| ".round(filesize($filePath) / 1024, 2)." KB | ".round(filesize($compressedFilePath) / 1024, 2)." KB (".round((filesize($filePath)-filesize($compressedFilePath))*100/filesize($filePath), 0)."% Size Reduced) |
This is a Free Online Tool to Compress JPEG Images to lowers file sizes.