You can use File::Type to get the type of a file in memory.
In reply to Re: Upload in-memory files with WWW:Mechanize by kyle in thread Upload in-memory files with WWW:Mechanize by hotsolutions