Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I've read over a few posts concerning uploading files and I am looking at pp152-5 in Lincoln Stein's book on using cgi.pm. Right now, I am just toying around with uploading a file from the local hard drive to the server. All I am doing in my current script is is uploading the file and then trying to print its contents to the web browser window. However, instead of the file's contents, I am just getting the file's name.

## cgi.pm parameters use CGI; #use CGI::Carp qw(fatalsToBrowser carpout); $CGI::DISABLE_UPLOADS = 0; $CGI::POST_MAX = 24000; my $query = new CGI; $query = CGI->new(); my %formdata; my @formfields = $query->param; for my $field(@formfields) { $formdata{$field} = $query->param($field); } print <<FORM; <center> <form method="post" action="https://www.$domain/$self" enctype="multip +art/form-data"> <input type="hidden" name="mod" value="on"> <input type="file" name="upload" size="40"><p> <input type="image" src="$images/submitbutton.gif"> </form> </center> FORM ## end upload documents ## while(<$formdata{upload}>) { print; }

This is just a snippet of my code. It seems to upload the file, however when a user selects C:\somefile.txt, the while statement just prints out this same path, minus the backslash. Based on Mr. Stein's code on p153 of his book with an example of how to print a file out to a local file on the server, I had thought the above snippet would work.

Can someone please point me straight?

humbly -c


In reply to Uploading files using cgi.pm by c

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-24 09:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found