Leader of Birmingham.pm [pm.org] and a CPAN author [cpan.org]. Co-organised YAPC::Europe in 2006 and the 2009 QA Hackathon, responsible for the YAPC Conference Surveys [yapc-surveys.org] and the QA Hackathon [qa-hackathon.org] websites. Also the current caretaker for the CPAN Testers websites and data stores.
If you really want to find out more, buy me a Guinness
Unfortunately it breaks
The reason is due to the fact that File::Spec cannot cope with different file specifications when used in a cross platform way. In the scenario above the user is using a browser on a Win32 box, but the code is running on a Unix box, thus the File::Spec::Unix.pm is loaded.
The following code:
my $source = "c:\mydirs\myfile.doc"; # the value from the HTML file form field
my ($volume,$directories,$filename) = splitpath($source);
So that when I try to save "/var/www/mysite/html/downloads/c:\mydirs\myfile.doc" if fails miserably.
I now use a simple regex to extract everything from the last directory delimiter (if there is one) to the end of the string. I guess it was a bit pointless calling another function to do it, but at least it highlighted the problem.