physi has asked for the wisdom of the Perl Monks concerning the following question:
<HTML> <HEAD> <TITLE>Upload</TITLE> </HEAD> <BODY> <FORM ACTION="/perl-cgi/upld" METHODE="POST" ENCTYPE="multipart/form- +data"> <INPUT TYPE="FILE" NAME="datei"> <P> <INPUT TYPE="SUBMIT"> </BODY> </HTML>
#!/usr/bin/perl use warnings; use strict; use HTML::Template; use CGI; my $template = HTML::Template->new(filename => 'upld.tmpl'); my $cgi = new CGI; if ($cgi->param('datei')) { loadpic($cgi); exit; } print "Content-Type: text/html\n\n"; print q(<link rel="stylesheet" type="text/css" href="/pds392/style.css +"> <style type="text/css"></style>); print $template->output; sub loadpic { my $cgi = shift; my $file = $cgi->param('datei'); my $fh = $cgi->upload('datei'); print "<HTML><BODY>$file<br></BODY></HTML>"; open OUT, ">/tmp/1.pic.jpg"; my $buffer; while (read $fh, $buffer, 512) { print OUT $buffer; } print "Content-Type: text/html\n\n"; close OUT; exit; }
my $fh is allways undef and the script dies, but $file contains the choosen filename!!!
Why ? Can this behavior result of using this script with mod_perl ? Or is there something I've missed ?
Cheers
----------------------------------- --the good, the bad and the physi-- -----------------------------------
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI upload and mod_perl
by bassplayer (Monsignor) on Feb 19, 2003 at 23:56 UTC | |
by physi (Friar) on Feb 20, 2003 at 00:02 UTC | |
|
•Re: CGI upload and mod_perl
by merlyn (Sage) on Feb 19, 2003 at 23:59 UTC | |
by physi (Friar) on Feb 20, 2003 at 00:06 UTC | |
by merlyn (Sage) on Feb 20, 2003 at 07:11 UTC | |
by adrianh (Chancellor) on Feb 20, 2003 at 12:17 UTC | |
|
Re: CGI upload and mod_perl
by hv (Prior) on Feb 20, 2003 at 00:03 UTC | |
by Coruscate (Sexton) on Feb 20, 2003 at 06:26 UTC | |
by hv (Prior) on Feb 20, 2003 at 18:47 UTC | |
by Tomte (Priest) on Feb 20, 2003 at 12:31 UTC |