if ($request_data[‘image_name’][‘tmp_name’]) {
$file = $request_data[‘image_name’];
$ext = substr(strtolower(strrchr($file[‘name’], ‘.’)), 1); //get the extension
$arr_ext = array(‘jpg’, ‘jpeg’, ‘png’); //set allowed extensions
$setNewFileName = time() . “_” . rand(000000, 999999);
$imageFileName = WWW_ROOT . ‘uploads/Student/student_image/’ . $setNewFileName . ‘.’ . $ext;
}
if (in_array($ext, $arr_ext)) {
move_uploaded_file($file['tmp_name'], WWW_ROOT . '/uploads/Student/student_image/' . $setNewFileName . '.' . $ext);
$imageFileName = $setNewFileName . '.' . $ext;
}