#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    4
    Rep Power
    0

    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.
  2. #2
  3. No Profile Picture
    Still Learning
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Montreal, Canada
    Posts
    55
    Rep Power
    40
    Use CGI.pm features
    See http://www.daniweb.com/software-development/perl/threads/69164/basic-perl-web-upload-script#

    For an example.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Apr 2009
    Posts
    1,967
    Rep Power
    1225
    It might be best to point the OP to the actual CGI documentation rather than an extremely short and questionable file upload example.

    perldoc CGI

    Here's a better and more complete tutorial on the file upload process.
    How to Upload Files using the CGI.pm Module and Perl

    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.
    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

    • admiraln agrees

IMN logo majestic logo threadwatch logo seochat tools logo