Fix bug with cancelling file uploads

If you choose a file(for example, on the edit problem page for "problem text"), and then choose cancel, the file upload will attempt to happen but since it won't have the primary key ID to write to(and since you don't actually want it to happen), you get a nice sql error due to the missing WHERE clause.

This simple fix just moves that block inside the check for the cancel button, which solves this problem.