in reply to File::Basename and File::MMagic for File Downloads from Website
Hi,
You can try like this:
use strict; use FileUpload::Filename; # Usually used in combination with the upload handler, so it will be # implicitely set. $ENV{HTTP_USER_AGENT} = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT + 5.1; .NET CLR 2.0.50727; Zune 2.0)'; my $name = FileUpload::Filename->name({ filename => 'Z:\my_files\docs\some_kind_of_manual.pdf', }); print "[$name]\n"; $name = FileUpload::Filename->name({ filename => '/home/someguy/file.txt', }); print "[$name]\n"; $name = FileUpload::Filename->name({ filename => 'home:anotherguy:A Music Song.mp3', }); print "[$name]\n";
Output:
[some_kind_of_manual.pdf] [file.txt] [A_Music_Song.mp3]
Curiously with the agent set as IE, it works for the three inputs :-)
Regards,
|
---|