Can anyone help me resize an image in core php. Can anyone write code for me to resize an image using core php. Here is my code:
public function add_images(){
$image=$_FILES['file'];
if(!empty($image)){
if($image['error']==0){
$imgName = pathinfo($_FILES['file']['name']);
$ext = $imgName['extension'];
$rand=mt_rand(5,1000000000).'.'.$ext;
$destination = base_path() . '/public/images/ListingImages/';
if(move_uploaded_file($image['tmp_name'], $destination.$rand)){
echo "moved"; die;
}
}
}
}
This code works fine for me. But when the user uploads an image it should be resized to 300x300.