Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: File::Basename and File::MMagic for File Downloads from Website

by fmerges (Chaplain)
on Nov 21, 2008 at 04:16 UTC ( [id://725053]=note: print w/replies, xml ) Need Help??


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,

fmerges at irc.freenode.net

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://725053]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-16 15:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found