Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upload file to server WITHOUT using CGI.pm

Status
Not open for further replies.

c4n

Programmer
Mar 12, 2002
110
SI
How can I upload a file to my server WITHOUT using CGI.pm module (UNIX server)? Because the ENCTYPE is set to "multipart/form-data" I can't (don't know how to) get variables from the HTTP POST otherwise then using CGI.pm.

This is what I've been using so far, but it is important that I can do this without using CGI.pm:

use CGI;
$q=new CGI;
my $file = $q->param("FILE");

# here is some extension checking which isn't important now

open (OUTFILE, ">outfile.jpg") || die "Can't copy file to the server. Please notify site administrator";
while (my $bytesread = read($file, my $buffer, 1024)) {print OUTFILE $buffer;}
close (OUTFILE);

# end then continue what you've been doing


Thanks!
 
Have a look-see here:
It describes more what the multipart form data looks like than how to parse it, but you should be able to take a little something from it.

----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
Interesting reading, thanks! I'll be able to go on from here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top