Bill and all,

I think I'm getting closer. But when I upload a file I get the error: "CGI open of tmpfile: Permission denied".

Now what?

Jerry

From: "$Bill Luebkert" <[EMAIL PROTECTED]>
To: Jerry Kassebaum <[EMAIL PROTECTED]>
Subject: Re: File Upload
Date: Mon, 04 Dec 2006 07:09:35 -0800

Jerry Kassebaum wrote:

> Sorry I wasn't clear on what I was trying to do. I want the visitor to be > able to either type in text in the box, OR send it in as a text file if he
> has it on his hard drive.

Try this (adjust $tmpdir for your situation) :


#!/usr/bin/perl

use strict;
use warnings;
use CGI qw/:standard/;
use CGI::Carp qw(carpout fatalsToBrowser);

# place to store files - change me if you like

my $tmpdir = $ENV{TEMP} || "C:/temp";

print header;
print start_html;

if (param ('textAreadomains')) {

        print h1 'Hi - got your domains:',
        p (
          param ('textAreadomains'),
        ),

} elsif (param ('fileDomains')) {

        my $filename = param ('fileDomains');
        my $tmppath = "$tmpdir/$filename";
        my $text;

        my $size = 0;
        while (my $bytes = read $filename, my $buffer, 4096) {
                $text .= $buffer;
                $size += $bytes;
        }
        close OUT;
        close $filename;

        print h1 'Hi - got your file:',
        p (
          param ('fileDomains'),
        ),
        p ("Content: ", textarea (-name, 'textAreadomains', -rows, "15",
          -cols, "75", -default => $text),
        ),

} else {

        print h1 ('Hi - pick one to input'),
        start_form,
        p ("Enter domain names, one per line: ", textarea (-name,
          'textAreadomains', -rows, "15", -cols, "75"),
        ),
        submit,
        end_form,
        hr,
        start_multipart_form,
        p ("Or upload a text file: ",
          filefield (-name, 'fileDomains'),
        ),
        submit,
        end_form,
        hr;
}

print end_html;

__END__

--
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

_________________________________________________________________
All-in-one security and maintenance for your PC.  Get a free 90-day trial! http://clk.atdmt.com/MSN/go/msnnkwlo0050000002msn/direct/01/?href=http://clk.atdmt.com/MSN/go/msnnkwlo0050000001msn/direct/01/?href=http://www.windowsonecare.com/?sc_cid=msn_hotmail

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to