Hi there, Me has a problem: I made a script which was able to upload a file, read 'post'-data, and query-string-data, without using a single module. (Except perl itself off course).
Now I changed the script a bit to fit in with the rest of my pages, and 'taadaah', it's not working anymore.

It seems as if the script can't parse the vars anymore, since when I call "if ($name) {...}" doesn't even react, even though I'm sure to have a var which is called 'name'.

Here is part of the form:
<form action="main.cgi?afd=upload" method="post" enctype="multipart/fo +rm-data" name="form" id="form" target="_top"> <input type="file" size=25 name="upload_foto" id="upload_foto" value=" +$filename" tabindex=2> <input type="text" size=25 name="naam" id="naam" value="$naam" tabinde +x=1>
Here is the script:
sub Parse_Form { if ($ENV{'REQUEST_METHOD'} eq 'GET') { @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); if ($ENV{'QUERY_STRING'}) { @getpairs =split(/&/, $ENV{'QUERY_STRING'}); push(@pairs,@getpairs); } } else { print "Content-type: text/html\n\n"; print "<P>Use Post or Get"; } foreach $pair (@pairs) { ($key, $value) = split (/=/, $pair); $key =~ tr/+/ /; $key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~s/<!--(.|\n)*-->//g; if ($formdata{$key}) { ## maakt er een Array van als key al vo +orkomt $formdata{$key} .= ", $value"; } else { $formdata{$key} = $value; } } } if ($naam) { print "Content-type: text/html\n\nGelukt om in die kut-sub te komen."; exit; }
And I'm so very sure it used to work...
PLEASE??????? I don't get it...

In reply to Can I do a file upload without using any modules? by frinky

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.