Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: checking file types in a perl upload scriptby rob_au (Abbot) |
on Feb 16, 2002 at 08:28 UTC ( [id://145826]=note: print w/replies, xml ) | Need Help?? |
A simple search of this site would have revealed a number of nodes relating to CGI-based file upload, including one from myself here. This question could also have been answered by having a read through some of the documentation for CGI, specifically under the heading "Creating a file upload field". However, it should be noted, that you should not necessarily trust the extension of the file name supplied with the binary stream. As such, depending upon the intended application of the uploaded files, it would be wise to make use of a module such as File::MMagic (or the shell command file if installed), which allows for the identification of file types based upon file names and file content - This allows files to be verified that the file content type matches the name given.
perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'
In Section
Seekers of Perl Wisdom
|
|