Florian Merges > FileUpload-Filename > FileUpload::Filename

Download:
FileUpload-Filename-0.02.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.02   Source  

NAME ^

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

SYNOPSIS ^

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

print $filename;

DESCRIPTION ^

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 ^

name

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

DIAGNOSTICS ^

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 ^

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 ^

Florian Merges <fmerges@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (C) 2006 by Florian Merges

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: