In case it's not clear to you, uploadInfo is returning undef -- that's the undefined value the error message is talking about. So the question becomes why is uploadInfo returning undef? And we'd need to see the source of uploadInfo and know what the value of $filename is to answer that.
Caution: Contents may have been coded under pressure.