FileUpload::Filename - Return the name of an uploaded file


FileUpload-Filename documentation  | view source Contained in the FileUpload-Filename distribution.

Index


NAME

Top

FileUpload::Filename - Return the name of an uploaded file

SYNOPSIS

Top

my $filename = FileUpload::Filename->name({ filename => $file });

print $filename;

DESCRIPTION

Top

As you can read on CGI, some browsers, when uploading a file, return the path to the file, using the path conventions of their OS. This could be annoying if you want to use the same name.

This module makes use of HTTP::BrowserDetect to know which OS the client is running in order to set the right FS type for File::Basename.

It also tries to normalize the filename by substituting spaces, colons, and all this usual stuff, with underscores.

E.g.:

 C:\My Music\Cool Artist - Great Song.mp3 -> Cool_Artist_-_Great_Song.mp3

METHODS

Top

name

 my $name = FileUpload::Filename->name({
    filename  => $cgi->param('uploaded_file'),  # Required
    agent     => $ENV{'HTTP_USER_AGENT'},       # Optional
 });

DIAGNOSTICS

Top

Must provide a file name

You have called the method without providing the required parameter. See name.

Can't get a UA to work with

You haven't provided a UA, or you don't have a HTTP_USER_AGENT environment variable.

Can't determine OS for given User Agent, defaulting to Unix

This is a warning message that informs that it will use the Unix file conventions to try to get a clean file name.

This happens if the HTTP::BrowserDetect fails to identify the users OS.

NOTES

Top

VERBOSE - Turn off warning messages

Just put the following before calling this module.

 sub FileUpload::Filename::VERBOSE { 0 };

Example:

 sub FileUpload::Filename::VERBOSE { 0 };
 use FileUpload::Filename;

DEBUG - Turn on debugging messages

Just put the following before calling this module.

 sub FileUpload::Filename::DEBUG { 1 };

Example:

 sub FileUpload::Filename::DEBUG { 1 };
 use FileUpload::Filename;

AUTHOR

Top

Florian Merges <fmerges@cpan.org>

COPYRIGHT AND LICENSE

Top


FileUpload-Filename documentation  | view source Contained in the FileUpload-Filename distribution.