FileUpload::Filename - Return the name of an uploaded file
my $filename = FileUpload::Filename->name({ filename => $file });
print $filename;
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
my $name = FileUpload::Filename->name({ filename => $cgi->param('uploaded_file'), # Required agent => $ENV{'HTTP_USER_AGENT'}, # Optional });
You have called the method without providing the required parameter. See "name".
You haven't provided a UA, or you don't have a HTTP_USER_AGENT environment variable.
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.
Just put the following before calling this module.
sub FileUpload::Filename::VERBOSE { 0 };
Example:
sub FileUpload::Filename::VERBOSE { 0 }; use FileUpload::Filename;
sub FileUpload::Filename::DEBUG { 1 };
sub FileUpload::Filename::DEBUG { 1 }; use FileUpload::Filename;
Florian Merges <fmerges@cpan.org>
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.
To install FileUpload::Filename, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FileUpload::Filename
CPAN shell
perl -MCPAN -e shell install FileUpload::Filename
For more information on module installation, please visit the detailed CPAN module installation guide.