Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

[Editor: <code> tags added just before moving this to Seekers of Perl Wisdom.]
#!/opt/ZDperl/bin/perl use CGI; use Fcntl qw(:flock); $mycgi = new CGI; print $mycgi->header; # get the file from the input stream $upload = $in{"UPLOAD"}; # check if it's there, and write it to disk if ($upload) # if it's plain text { open (TEXT, ">filename.txt") || die "$!"; unless (flock (TEXT, LOCK_EX)) {die "$!";} print"i had to find out if it works\n"; while (<$upload>) { print TEXT ; } close(TEXT); }
I can't seem to get the contentss of the file i am uploading ,is there a way i can check where i am uploading the file and the contents of it.

Replies are listed 'Best First'.
Re: error uploading a file
by damian1301 (Curate) on Jan 04, 2001 at 03:57 UTC
    The problem is that CGI.pm uses param() to get parameters and not %in. It should work here...
    use CGI qw/:all/; use Fcntl qw(:flock); print header; # get the file from the input stream $upload = param("UPLOAD"); # check if it's there, and write it to disk if ($upload){ open (TEXT, ">filename.txt") || die "$!"; flock (TEXT, LOCK_EX) || die "$!"; print"i had to find out if it works\n"; while (<$upload>) { print TEXT ; } close(TEXT); }
Answer: error uploading a file
by coreolyn (Parson) on Jan 04, 2001 at 04:09 UTC

    And the catogory is?

    First your post should have been posted in 'Seekers of Perl Wisdom' or SOPW as it is often referred to here. Catagorical Answers are for specific questions.

    Second you need to learn about <code> tags. Surrounding your code between <code> (code here) </code> would have your code look a little more like this:

    #!/opt/ZDperl/bin/perl use CGI; use Fcntl qw(:flock); $mycgi = new CGI; print $mycgi->header; # get the file from the input stream $upload = $in{"UPLOAD"}; # check if it's there, and write it to disk if $upload) # if it's plain text { open (TEXT, ">filename.txt") || die "$!"; unless (flock (TEXT, LOCK_EX)) {die "$!";} print"i had to find out if it works\n"; while (<$upload>) { print TEXT ; } close(TEXT);

    This is still a mess but you get the gist. Maybe you should repost it the way YOU want it to be read in SOPW.

    coreolyn