file upload failing for some users

L

Larry

I'm running a CGI script that handles uploading a file using
"start_multipart_form" and "filefield". For me and other users, it
works fine, but for 1 user, the script presents the form fine but when
she submits it with the file to upload, it pauses like it's uploading,
but the browser eventually fails with "This page connot be displayed".
If I take the exact same file that she tried to upload and upload it
from home, it works fine.

The file is about 100K and takes only about 20 seconds to upload, so
it's not a browser timeout issue. I had her try several times on
different days... same problem. I even went to her location and tried
it myself... same problem.

The only thing I can think of is some sort of firewall/network oddity
at her location. But if so, what can I do at the server to resolve
that?
 
B

Brian Wakem

Larry said:
I'm running a CGI script that handles uploading a file using
"start_multipart_form" and "filefield". For me and other users, it
works fine, but for 1 user, the script presents the form fine but when
she submits it with the file to upload, it pauses like it's uploading,
but the browser eventually fails with "This page connot be displayed".
If I take the exact same file that she tried to upload and upload it
from home, it works fine.

The file is about 100K and takes only about 20 seconds to upload, so
it's not a browser timeout issue. I had her try several times on
different days... same problem. I even went to her location and tried
it myself... same problem.

The only thing I can think of is some sort of firewall/network oddity
at her location. But if so, what can I do at the server to resolve
that?


Her ISP may be timing out the connection.
 
L

Larry

A bit more info... here is the exact error message given by Internet
Explorer:

Cannot find server or DNS error.

I have never seen a Perl script trigger that particular browser error.
 
I

Ilmari Karonen

Larry said:
A bit more info... here is the exact error message given by Internet
Explorer:

Cannot find server or DNS error.

I have never seen a Perl script trigger that particular browser error.

Is the script that receives the file on the same server as the one
that generates the form? If they are, is the action URL in the form
absolute or relative? If absolute, does it have the exact same
hostname as the URL of the form itself?

Or does the upload script perhaps respond with a redirect? That could
cause problems for a number of reasons (hostname differences, browser
implementation of redirected POST requests, etc).
 
X

xhoster

Larry said:
A bit more info... here is the exact error message given by Internet
Explorer:

Cannot find server or DNS error.

Is there any problem for which IE does *not* give that error message?

Try it with FireFox and see what error message it gives.

Xho
 
G

gimme_this_gimme_that

Could be an issue where the server "can't find" the last character
(EOF character) of the file.

When you upload it locally, are you on the server?

Can she upload small text files ?
 
G

gimme_this_gimme_that

It's not an http thing it's a computer OS thing.

Perhaps you are fortunate enough to do all your stuff on a UNIX
variant - but with Wintel - it can be an issue.

Obviously, the symptoms are one of a "can't find the EOF" issue.
That might not be the cause, but the symptoms match.

Of course if you wanted to make a production out of it you could
download a demo version of LoadRunner, record the http post
case from the local box and then record it from the remote
box and compare the record logs. Then you could view the http
sessions in human readable format.
 
S

Sherm Pendley

Larry said:
That's a good test... I could have her do that.

What's a good test? You could have who do what?

Please quote enough of the message you're reponding to, for your response
to make sense when viewed by itself. Not everyone is using Google Groups to
access usenet, nor is everyone viewing a hierarchical list of all messages
in a thread.

sherm--
 
L

Larry

There is only 1 script... it both generates the form and receives the
file. (It checks the CGI paramters to tell which one it's supposed to
do.) The action URL is absolute but without a hostname... in other
words, it starts with a slash, not "http://".

The upload script does not respond with a redirect... it responds with
"print header;", etc (which generates "Content-type: text/html\n\n")
 
L

Larry

FireFox is a good suggestion. I should have thought of that the first
time (although I probably wouldn't have had time to install it that
day). But that would require another site visit, which I'd like to
avoid.
 
L

Larry

Here's the simplified code:

#!/usr/local/bin/perl

use strict;
use warnings;
use CGI qw/:standard *table -no_xhtml/;
use CGI::Carp 'fatalsToBrowser';
use Fcntl ':flock';

$CGI::pOST_MAX = 1024 * 2000;

my $home = "/home/www";
my $www = "/var/www";
my $outDataFname = "$www/newsletter.pdf";

sub updatePdf {
open my $lock, ">$home/pdf_lock" or die "Can't open lock file:
$!\n";
flock($lock, LOCK_EX | LOCK_NB) or die "Can't get the lock: $!\n";

my $upF = upload('up_pdf') or die "No upload file\n";
my $upData;
{
local $/;
undef $/;
$upData = <$upF>;
}

open my $outF, ">$outDataFname" or die "Can't open output: $!\n";
binmode $outF;
print $outF $upData;
close $outF;

print p, b("New PDF uploaded successfully.");
flock($lock, LOCK_UN);
close($lock);
}

print header;
my $title = 'Upload PDF';
print start_html({title => $title});
print h2($title);
if (param()) {
updatePdf();
}
else {
print p, start_multipart_form();

print "PDF file: ", br,
filefield(-name => 'up_pdf',
-size => 50), p
submit(-value => 'Upload'), br;
print end_form();
}

print end_html;
 
S

Sherm Pendley

Larry said:
Hmmm... it worked once for her today. Then she tried it again later
and it didn't.

What worked? For whom???

Please, quote the enough of the message you're replying to for your message
to make sense by itself. Not everyone uses Google Groups, and not everyone
has a list of older messages to look back on.

sherm--
 
J

J. Gleixner

Larry said:
Here's the simplified code:
[...]
open my $lock, ">$home/pdf_lock" or die "Can't open lock file:$!\n";

See below, for using 'or' or '||'. There are times where you use it
correctly, as in the next line, and times where you don't.
flock($lock, LOCK_EX | LOCK_NB) or die "Can't get the lock: $!\n";
my $upF = upload('up_pdf') or die "No upload file\n";
my $upData;
{
local $/;
undef $/;

It's already undef(ined)...
$upData = <$upF>;
}

....but why read the entire contents of the file into memory only to
print it to a file?
open my $outF, ">$outDataFname" or die "Can't open output: $!\n";

Choose one of the following:

open( my $outF, ">$outDataFname" ) or die ...
open my $outF, ">$outDataFname" || die ...
binmode $outF;
print $outF $upData;
close $outF;

print p, b("New PDF uploaded successfully.");
flock($lock, LOCK_UN);
close($lock);

Close'ing the file will unlock it. Close it as soon as you're finished
with the content.
}

print header;
my $title = 'Upload PDF';
print start_html({title => $title});
print h2($title);

Can shorten that to one call to print.
if (param()) {
updatePdf();
}
else {
print p, start_multipart_form();

print "PDF file: ", br,
filefield(-name => 'up_pdf',
-size => 50), p

Need a ',' after 'p'??
submit(-value => 'Upload'), br;
print end_form();

You can shorten that to use just one call to "print".


If you're having problems, add some error checking, as outlined in
perldoc CGI for file uploads, and take a look at your error log.
 
J

John W. Krahn

J. Gleixner said:
Choose one of the following:

open( my $outF, ">$outDataFname" ) or die ...
open my $outF, ">$outDataFname" || die ...

Wrong! 'or' has low precedence so the parentheses are not required while '||'
has higher precedence so the parentheses ARE required.

open my $outF, ">$outDataFname" || die ...

Is interpreted as:

open my $outF, ( ">$outDataFname" || die ... )

And it will never die as ">$outDataFname" is always true.


perldoc perlop



John
 
L

Larry

New info... it works through dialup but not through their broadband (it
works through other people's broadband, though). What could possibly
cause that?
 

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

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top