0

Hi Friend's need help how to reduce the image size before uploading ans each image have 5MB this is my code

public static function upload_file($input, $path="uploads")
{
    $files = array();  
    if($input){
        foreach ($input as $file) {
            if ($file){
                $fileSize = $file->getSize();              
                $destinationPath = base_path() . "/$path/";
                if(!file_exists($destinationPath)){
                    mkdir($destinationPath);
                }
                $filename = $file->getClientOriginalName();
                $extension = $file->getClientOriginalExtension();
                $fileName = ServicewebHelper::gen_uuid() . '.' . $extension;
                $file_object['fileName'] = $fileName;
                $file_object['filePath'] = "/$path/" . $fileName;
                $file_object['fileSize'] = $file->getSize();
                $file_object['fileType'] = $file->getMimeType();
                $file_object['fileExtension'] = $extension;
                $file_object['fileOriginalName'] = $filename;
                $file->move($destinationPath, $destinationPath . $fileName, 0777);
                chmod($destinationPath . $fileName, 0777);
                $files[] = $file_object;
            }
        }
    }
    return $files;
}  

any one please help me how to resize the image when before uploading

sivakumar.s
  • 87
  • 1
  • 2
  • 14

0 Answers0