I have a web host that doesn't have the CGI-LIB module (maybe for security reasons that I saw mentioned at http://www.rice.edu/perl4lib/archives/2000-03/msg00022.html ), and I'm trying to read an uploaded file submitted by a form. I can read non-uploaded data from the form using the CGI module, but for some reason, the following doesn't print out the uploaded data:

from form:
<html><body> <form enctype="multipart/form-data" action="path_to_script_that_reads_ +non_uploaded_ data_only_for_some_reason" method="post"> <p>Upload test<input type="file" size="45" name="UploadedFile"></p> <input type="submit" value="Submit"> <input type="reset" value="Reset"> </form></body></html>
from script:
use CGI; $CGI::POST_MAX = 4000; $CGI::MULTIPART; ### Doesn't seem to be needed in script for reading f +orm data, but I put it here in desperation $fdata = CGI->new(); $Test_Field = $fdata->param('UploadedFile'); print"$Test_Field";exit;
Seems like it should at least print out the file name, but it doesn't. I might try to create the file upload part of the form from the script, but I already have a HTML form for the other fields, so I'd like stick with all HTML.

I read that LWP can be used for this. Must I figure out how to do that, or is there some way I can fix the above script and just use the plain old CGI module?

In another experiment, I used the script at http://www.speakeasy.org/~cgires/cgi-tour.html#summary which is a modified version of CGI_LIB, but it's old and didn't work on a plain text file at all, and garbled a cgi script that I tried uploading. I might try rewriting the parsing routine in that script, but it seems like a long, sloppy way to handle this, especially since it's only for one form field.

Any suggestions?

In reply to Reading file uploads by Wassercrats

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.