file upload failing for some users

Discussion in 'Perl Misc' started by Larry, Jun 23, 2005.

  1. Larry

    Larry Guest

    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?
     
    Larry, Jun 23, 2005
    #1
    1. Advertising

  2. Larry

    Brian Wakem Guest

    Larry wrote:

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


    --
    Brian Wakem
     
    Brian Wakem, Jun 23, 2005
    #2
    1. Advertising

  3. Larry

    Larry Guest

    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.
     
    Larry, Jun 23, 2005
    #3
  4. Larry <> kirjoitti 23.06.2005:
    > 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).

    --
    Ilmari Karonen
    To reply by e-mail, please replace ".invalid" with ".net" in address.
     
    Ilmari Karonen, Jun 23, 2005
    #4
  5. Larry

    Guest

    "Larry" <> wrote:
    > 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

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Jun 23, 2005
    #5
  6. Larry

    Guest

    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 ?
     
    , Jun 23, 2005
    #6
  7. <> kirjoitti 23.06.2005:
    > Could be an issue where the server "can't find" the last character
    > (EOF character) of the file.


    No. HTTP file upload doesn't work that way.

    --
    Ilmari Karonen
    To reply by e-mail, please replace ".invalid" with ".net" in address.
     
    Ilmari Karonen, Jun 23, 2005
    #7
  8. Larry

    Guest

    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.
     
    , Jun 24, 2005
    #8
  9. "Larry" <> writes:

    > 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--
     
    Sherm Pendley, Jun 24, 2005
    #9
  10. Larry

    Larry Guest

    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")
     
    Larry, Jun 24, 2005
    #10
  11. Larry

    Larry Guest

    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.
     
    Larry, Jun 24, 2005
    #11
  12. Larry

    Larry Guest

    That's a good test... I could have her do that.
     
    Larry, Jun 24, 2005
    #12
  13. Larry

    Larry Guest

    I'm not on the server when I upload it. I'm on my home computer.
     
    Larry, Jun 24, 2005
    #13
  14. Larry

    Larry Guest

    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;
     
    Larry, Jun 24, 2005
    #14
  15. "Larry" <> writes:

    > 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--
     
    Sherm Pendley, Jun 24, 2005
    #15
  16. Larry

    Larry Guest

    Hmmm... it worked once for her today. Then she tried it again later
    and it didn't.
     
    Larry, Jun 24, 2005
    #16
  17. Larry

    J. Gleixner Guest

    Larry wrote:
    > 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. Gleixner, Jun 24, 2005
    #17
  18. J. Gleixner wrote:
    > Larry wrote:
    >
    >>
    >> 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 ...


    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
    --
    use Perl;
    program
    fulfillment
     
    John W. Krahn, Jun 24, 2005
    #18
  19. Larry

    Larry Guest

    New info... it works through dialup but not through their broadband (it
    works through other people's broadband, though). What could possibly
    cause that?
     
    Larry, Jul 1, 2005
    #19
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2FyYXY=?=

    Upload a file without file Upload control - ASP.Net

    =?Utf-8?B?U2FyYXY=?=, Aug 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,581
    Bruce Barker
    Aug 3, 2005
  2. Heather Fraser
    Replies:
    0
    Views:
    664
    Heather Fraser
    Jul 5, 2004
  3. Steven Bethard

    PyPI bdist_wininst upload failing

    Steven Bethard, May 26, 2007, in forum: Python
    Replies:
    6
    Views:
    441
    Steven Bethard
    May 27, 2007
  4. c676228
    Replies:
    4
    Views:
    366
    Adrienne Boswell
    Mar 17, 2008
  5. Neil Gould

    IE8 failing with some ASP code...

    Neil Gould, Apr 3, 2009, in forum: ASP General
    Replies:
    1
    Views:
    164
    Neil Gould
    Apr 3, 2009
Loading...

Share This Page