Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Want to parse your very own attachment uploads without
using a module? That's what you were asking.
Simpliest way i've used without a module is called 'cgi-lib.pl'
It's a downloadable perl script you include in your perl
script and can run on your webserver just fine.
http://cgi-lib.berkeley.edu/

I didn't get too deep into your code. I'd rather submit
some helpful pointers which may guide you on your way.


Basically you want perl to receive the form inputs from an
html page on a visitor's computer. Two areas need
setting up to do this by yourself with no module:
1. html form needs an enctype modifier.
Without this, your browser sends the
contents of your form as a simple buffer.
Make sure you have the following
included in your html form tag code:
<form method=post enctype='multipart/form-data'>
Now that you did that, you need to read what
was received in perl. There are a ton of helpful
modules which will do this for you 1000 times better than
little ole me could convey, but you said virtual host,
without a module. Again, i remind you of cgi-lib.pl, see above.
Tinkering with multi-type forms isn't an entire waste of
time. You start to see how MIME works
which can be handy for custom email readers.

To start, take a look at what perl is sending you.
Self-testing is the best learning tool here.
In particular take a look at your ENV variables
when you upload a file to your test script.
In particular, look at $ENV{'CONTENT_TYPE'}.
$ENV{'CONTENT_TYPE'} has a boundary modifier, parse this.
You will use the boundary to delimit the remainder of your
form. Once you know the delimiter you can split your
uploaded content into it's seperate parts and begin to hack away.
Each part has a HEAD and a BODY. The head tells
you the filename, and describes the content.
The BODY is the content (i.e. your image, or file)
described by the HEAD.
The HEAD and BODY are seperated by \n\n
#Print your ENV variables so you can find your boundary foreach $key(keys %ENV){ print "$key...$ENV{$key}\n"; }
jtrue

In reply to Re: allowing form uploading by true
in thread allowing form uploading by sulfericacid

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 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? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2022-08-15 15:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?