May 16, 2022
5
Level 2
Reduce image size while uploading
i've this script it helps me to move the uploaded image and its working well,i'm trying to find a solution to reduce the image size while uploading it is this available ? here's the code if someone can help
if ((isset($_FILES['photo']['name']) && !empty($_FILES['photo']['name']))) {
$ds = DIRECTORY_SEPARATOR;
$tempFile = $_FILES['photo']['tmp_name'];//3
$file_extension = pathinfo($_FILES['photo']['name'] , PATHINFO_EXTENSION); /// get EXTENSION from file
$nameFile = rand() . '-' . strtotime(date("Y-m-d h:i:s")) . '.' . $file_extension; /// filename with EXTENSION
$targetPath = realpath(dirname(_FILE_) . '/..'. '/..'. '/..') . $ds . 'includes/img/shops/'; // path file
$targetFile = $targetPath . $nameFile; // path file with filename
move_uploaded_file($tempFile, $targetFile); // move file to path folder
} else {
$nameFile = NULL;
}
Level 122
The most common solution is Intervention Image https://image.intervention.io/v2
1 like
Please or to participate in this conversation.