嗨朋友需要帮助如何在上传之前减小图像尺寸每个图像都有5MB这是我的代码
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;
}
任何人都可以帮我在上传之前如何调整图片大小