don't use location.reload

location.reload will keep current parameters (such as ?notice) which
then results in the notice message being showed on page reload.

Also checking if $file is empty is useless as it never (should) be.