Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: CGI.pm's upload gives local filename, not file itself

by jarich (Curate)
on Feb 03, 2002 at 22:54 UTC ( [id://143122]=note: print w/replies, xml ) Need Help??


in reply to Re: CGI.pm's upload gives local filename, not file itself
in thread CGI.pm's upload gives local filename, not file itself

Or you could use File::Basename which I believe is standard with the Perl distributions.
use File::Basename; my $new_file_name = basename($full_path_name, 'jpg|JPG'); # or $new_file_name = basename($full_path_name, '\..*'); # but this will return "James" from # "James.John.jpg"
or you could use split, or many other options. :)

jarich

Replies are listed 'Best First'.
Re: Re: Re: CGI.pm's upload gives local filename, not file itself
by giulienk (Curate) on Feb 04, 2002 at 07:58 UTC
    Using File::Basename isn't that easy indeed, cause you got to suggest him the operating system of the client.
    You can do it by checking CGI server variables but i prefer the regex way, it's more straight forward IMHO.
    Maybe split solution could be more readable, even if less efficient:
    my $new_file_name = pop @{[split /\/|\\/, $full_path_name]};
    $|=$_='1g2i1u1l2i4e2n0k',map{print"\7",chop;select$,,$,,$,,$_/7}m{..}g

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-03-19 06:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found