in reply to upload on different browsers

Offhand, without investigating too closely, I'd say that your problem is here:
($fn)=($fn=~/^.+\\(.+)/);
What you appear to be trying to do is take the filename and strip off any leading directory spec., leaving only the last portion. But what if there isn't any directory, and firefox is just sending the filename? Then $fn ends up as undef, which could mean that your open statement a few lines down fails badly.

I'd change that line to:

$fn =~ s{^.*[/\\]}{};
Not only will this still leave the variable defined if it doesn't include a directory spec., it's a bit clearer to someone reading the code that what you want to do here is strip off any path portion of the filename, leaving only the actual file.
-- @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

Replies are listed 'Best First'.
Re^2: upload on different browsers
by dannoura (Pilgrim) on Jul 16, 2004 at 18:55 UTC

    Thanks, that works (although I can't figure out why. If your reasoning is correct than IE shouldn't have accepted it either. Oh well). Thanks also for streamlining the sub. As for the last issue: it doesn't help to close FH;. I'm using the line

    if (check_filesize((-s FH), $size))

    to check if all the file got copied, so I have to have FH open after the while loop. Adding close FH; at the end of the script still doesn't do the trick. I still have a CGItemp file after the upload. Any othe ideas?

      At this point, I think your script is still erroring out somewhere, and the way I'd check where is to find the Apache error logfile and look at it.
      -- @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

        I checked it as you suggested. Nothing there (i.e. no errors reported at all, not even unrelated ones). I added an update to my original question: it seems that the files are not getting uploaded completely.

Re: upload on different browsers
by Smylers (Pilgrim) on Jul 17, 2004 at 08:50 UTC

    While I agree that the code is clearer with a substitution rather than capturing stuff in $1, the advantage of the latter is that it untaints the input, and it's definitely preferable for web scripts to run in taint mode. Something like this should work:

    ($fn) = ($fn =~ m#([^/\\]+)$#;

    However for getting the basename of a path I'd tend to use File::Basename — though that doesn't play well with the desire to untaint ...

    Smylers

Re: upload on different browsers
by Anonymous Monk on Jul 19, 2004 at 02:04 UTC
    Another thing to note is the CGI.pm has an inbuilt upload limit, its stored in the $CGI::POST_MAX variable. <snip> An attempt to send a POST larger than $POST_MAX bytes will cause param() to return an empty CGI parameter list. You can test for this event by checking cgi_error(), either after you create the CGI object or, if you are using the function-oriented interface, call <param()> for the first time. If the POST was intercepted, then cgi_error() will return the message "413 POST too large". </snip> http://www.perldoc.com/perl5.8.4/lib/CGI.html HTH