Proposed fix for blocking Step.5 of upgrade process

The function dirname returns the parent folder of the $securePath. This causes user input to be truncated from say /path/to/my/sk to /path/to/my. This parent folder may not have been made writable by the upgrade script even if the child is. In that case, the upgrade process stalls with an error that does not make sense to the user since the path he provided was writable.