Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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

by giulienk (Curate)
on Feb 03, 2002 at 13:37 UTC ( #143054=note: print w/replies, xml ) Need Help??

in reply to's upload gives local filename, not file itself

The behavior of sending the entire filepath to the server is peculiar to Internet Explorer. So you should filter the filename with a regex to have a valid filename. Something like the following could do:
my ($new_file_name) = $full_path_name =~ m!(?:.*\\|.*\/)?(.+)$!;
Update: well, it seems your problem was of another nature and already been solved: it's a bad habit to post before reading the full thread... sorry

Replies are listed 'Best First'.
Re: Re:'s upload gives local filename, not file itself
by jarich (Curate) on Feb 03, 2002 at 22:54 UTC
    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. :)


      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]};

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://143054]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2018-06-20 16:17 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.