Perhaps the user that runs the CGI, ie probably nobody, does not have permission to overwrite an existing /tmp/trashed. Check to see if the file already exists from the command line, and if so remove it.
Alternatively, try this:
use File::Copy;
...
move($newname, '/tmp/trashed') or die "Failed to move file: $!\n";