Also, in the if condition, check for $is_upload to take into account PHP configuration directive.