January 22nd, 2013, 03:45 PM
Handling files from HTML POST method with Perl
Please excuse my ignorance. It's my first time working with Perl and I'm finding it to be quite different from what I'm used to and rather difficult to wrap my head around.
I'm hoping someone out there might be able to point me in the right direction on how this particular problem might be handled - or even tell me that it can't. So here goes...
I have 'inherited' a Perl script that receives form data from a website, packages the data into a file and emails that file to a specified address. Being that Perl is renowned for handling textual data, it's a good fit. I'm looking to expand it a bit in the hopes that I will also be able to handle attached files that will also be emailed to the specified address.
I was planning to use no more than 3 INPUT type="file" tag in my HTML, allowing the user to select files from their computer. The problem I'm having is figuring out how to capture the files in the Perl script and to attach them with the existing $smtp->datasend commands.
Any help would be hugely appreciated. Thanks.
January 25th, 2013, 09:23 PM
Use CGI.pm features
For an example.
January 26th, 2013, 09:25 AM
It might be best to point the OP to the actual CGI documentation rather than an extremely short and questionable file upload example.
Here's a better and more complete tutorial on the file upload process.
How to Upload Files using the CGI.pm Module and Perl
I assume you're using the Net::SMTP module.
It would be much easier to use one of the higher level email modules, such as MIME::Lite, for attaching the files and sending the email.
Comments on this post