PerlEx uploading a text file
Hi all,
I have made an PerlEx code that uploads text file and writes it on the
screen (HTML page).
Here is the code:
<%
#!/usr/bin/perl -w
use CGI qw(:standard);
my $cgi = CGI->new();
my $filename = $cgi->param('filename');
print $filename . "
";
my $filehandle = $cgi->upload('filename');
# Wite file to HTML page
while (<$filehandle>)
{
print $_ . '
';
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Upload text file</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-8-i" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="-1" />
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="filename" id="filename" />
<input type="submit" />
</form>
</body>
</html>
# End of PerlEx code
The problem is that this code works some times and some times does not
work (using the exact same code with the same text file).
Any body have an idea why this happens and how to fix it?
Thanks a lot,
Ari
Re: PerlEx uploading a text file
490 wrote:
> I have made an PerlEx code that uploads text file and writes it on the
> screen (HTML page).
<snip>
> The problem is that this code works some times and some times does not
> work (using the exact same code with the same text file).
As has been said here many times, "does not work" is the worst possible
problem description.
Anyway, the CPAN module CGI::UploadEasy might be useful. It performs a
few checks and displays useful error messages when needed, which
prevents problems when you write upload applications.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Re: PerlEx uploading a text file
On Dec 25 2007, 10:20 am, Gunnar Hjalmarsson <nore... [at] gunnar.cc>
wrote:
> 490 wrote:
> > I have made an PerlEx code that uploads text file and writes it on the
> > screen (HTML page).
>
> <snip>
>
> > The problem is that this code works some times and some times does not
> > work (using the exact same code with the same text file).
>
> As has been said here many times, "does not work" is the worst possible
> problem description.
>
> Anyway, the CPAN module CGI::UploadEasy might be useful. It performs a
> few checks and displays useful error messages when needed, which
> prevents problems when you write upload applications.
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl
Hi,
I did the debug mode and get an error "400 Bad request (malformed
multipart POST)", this is after it works a couple of times.
Does anybody know what this error is?
Thanks a lot,
Ari