I am trying to write a toy script that will ask for an upload file and then echo that file back to the user on the browser. However, if I do this all in one script like the following, I get no echoed file. However, if I instead use a separate HTML form and submit to my script, it works fine. Here is the script and the HTML submission form. I would like to use just the script. Can anyone tell me why the script does not work by itself?

Thanks,
Sean

#!/usr/bin/perl
use strict;
use CGI;
use File::Temp;

my $q=new CGI();

my $value=$q->param('upload_file');


print $q->header(); print $q->start_html(); print $q->start_form(); print $q->filefield('upload_file'); print $q->submit(); print $q->end_form(); if ($q->param('upload_file')) { my $fh=$q->upload('upload_file'); while (<$fh>) { print $_; } } print $q->end_html();


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>normalize</title> </head>

<body>
<h1>normalize</h1>
<form method="post" action="http://128.231.144.116/cgi-bin/normalize.pl";; ENCTYPE="multipart/form-data">
<INPUT TYPE="file" NAME="upload_file">
<INPUT TYPE="submit">
</form>



<hr> <!-- Created: Tue Jul 27 12:09:36 EDT 2004 --> <!-- hhmts start --> Last modified: Tue Jul 27 12:11:20 EDT 2004 <!-- hhmts end --> </body> </html>


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to