PerlEx uploading a text file


4

490

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 . "<br />";

my $filehandle = $cgi->upload('filename');

# Wite file to HTML page
while (<$filehandle>)
{
print $_ . '<br />';
}

%>
<!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
 
Ad

Advertisements

G

Gunnar Hjalmarsson

490 said:
I have made an PerlEx code that uploads text file and writes it on the
screen (HTML page).

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.
 
Ad

Advertisements

4

490

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.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top