trim function is not working in model file of codeIgniter
trim() as in you code just remove space at beginning and end
trim($_FILES["servicePhoto"]['name'])
you want remove also space between words you need replace
str_replace(' ', '', $_FILES["servicePhoto"]['name']);
another codeigniter helper you can use is url_title()
function.
something like this will work for you.
url_title(trim($_FILES["servicePhoto"]['name']));
it replaces space with dash -
.