Look at
doc/features.file-upload.html in the Online Reference for more.
In your example the filename is stored in "$filename_name"; in "$filename" is the name of the temp file at your server.
You have to change/copy the file from the TEMP-Dir or it will be killed after the end of your script!