Forum Moderators: coopster & phranque

Message Too Old, No Replies

Form Variable Problem in CGI

Differences with standard vs. multipart/form data

         

jonrichd

3:41 pm on Feb 7, 2003 (gmt 0)

10+ Year Member



I am being forced to use CGI instead of PHP to upload files to the server to get around a size limitation by my ISP.

I found a script that does the upload just fine. What I want to do is to have a single form that gives the file to upload, along with some other fields with info on directory, user etc.

I am trying to parse the field/value pairs using the logic in message 3 of this post [webmasterworld.com], which works fine for a normal form. However it appears that when setting the form type to enctype="multipart/form-data", the field-value pairs are no longer separated by ampersands, so you get nothing.

Is there some workaround to this problem?

Thanks for the help.

stevedob

5:22 pm on Feb 7, 2003 (gmt 0)

10+ Year Member



You might want to take a look at an online article entitled "Uploading Files Using CGI and Perl" by Matt Doyle, available through YFSE ;)

amoore

6:21 pm on Feb 7, 2003 (gmt 0)

10+ Year Member



Have you taken a look at CGI.pm?
[search.cpan.org...]

It will help you handle getting all of the parameters, pulling in the file, checking for errors, and all kinds of stuff. I believe it's in the default perl install these days, too.

Ron_Carnell

7:10 pm on Feb 7, 2003 (gmt 0)

10+ Year Member



Certainly, cgi.pm or cgi-lib.pm are the easiest answers, especially if you're uploading only a single file at a time. If you'd like to roll your own, however, here's a decent in-depth tutorial on multipart forms (no affiliation).

Do-it-yourself form based file upload [arq.net]

jonrichd

11:09 pm on Feb 7, 2003 (gmt 0)

10+ Year Member



Finally, I have gotten this to work. Oddly enough, the Doyle sample code didn't run on my system -- the script crapped out on the query->upload statement. So, I kluged together my original solution with the CGI.pm, and got what I needed.

Thanks for the help.