take into account $php_errormsg
add is_writable($upload_dir) check