Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

upload errors

by eoin (Monk)
on Aug 26, 2003 at 22:50 UTC ( [id://286885]=perlquestion: print w/replies, xml ) Need Help??

eoin has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, I've had quite few problems with my whole project, here, here and here
As of late its been working grand but I changed a few things (of no relivence really). Nothing big. Maybe I deleted a char somewhere with out noticing??
Anywho, when I run this script it creates the folder and uploads the file but it seems to get stuck when it reaches the print command. I get a server error page instead of my html, such as
Internal Server Error The server encountered an internal error or misconfiguration and was u +nable to complete your request. Please contact the server administrator, support@netfirms.com and info +rm them of the time the error occurred, and anything you might have d +one that may have caused the error. More information about this error may be available in the server error + log.
I'm stumped. I dunno how things can go so wrong with a print command!!!!
Heres the script
#!/usr/bin/perl -wT use strict; use warnings; use diagnostics; use File::Spec::Functions; use CGI qw(:standard); open LOG, ">logfile" or die; our $ALBUM_DIR = "../www/albums"; my $user = param("user"); my ($album) = param("T1"); #=~ /([\w ]+)/; # Untaint the album dir nam +e my $albumdir = catdir( $ALBUM_DIR, $album ); unless ( -d $albumdir ) { mkdir $albumdir, 0775; } my @pics; for ( '', 0 .. 19 ) { push @pics, { idx => $_, name => (param("photo$_") =~ /.+([\w. ]+)/)[0], fh => upload("photo$_") }; } foreach my $pic (@pics) { my $name = $pic->{'name'}; my $fh = $pic->{'fh'}; my $idx = $pic->{'idx'}; my $filenm = catfile( $albumdir, "pic$idx.img" ); print LOG $idx . "\n"; unless($fh eq undef){ local *IMAGE; open IMAGE, ">", $filenm or die "Couldn't open $filenm for writing: $!"; binmode IMAGE; while (my $line = <$fh>) { print IMAGE $line or die "Couldn't write to $filenm: $!"; } close IMAGE or die "Couldn't close $filenm while writing: $!"; } } close(LOG); print qq(Content-type: text/html\n <HTML><HEAD> <META HTTP-EQUIV="refresh" CONTENT="01;URL=http://eoinmurphy00.netfirm +s.com/cgi-bin/albums.cgi?status=viewall&album=$album&user=$user"> </head><body></body></html>);
Thanks to every one whos helped me make this script.
Appriciate any help at all.


All the Best, Eoin...

If everything seems to be going well, you obviously don't know what the hell is going on.

Replies are listed 'Best First'.
Re: upload errors
by CombatSquirrel (Hermit) on Aug 26, 2003 at 23:41 UTC
    Not an answer to your problem, but are you sure that name => (param("photo$_") =~ /.+([\w. ]+)/)[0] does what you think it does? It simply stores the last charachter which is a letter, a number or a space under the hash key "name", because the first + is greedy and just gives up the last character in the character class so that the second + is satisfied. If you want to discard the first part, which does not contain these characters (I don't know your data), then think about a negated character class, along the lines of name => (param("photo$_") =~ /.[^\w. ]+([\w. ]+)/)[0]. But maybe I am mistaken anyways and this does what you intend to do.
    To your problem: CGI facilitates your HTML output (just from the docs, I could never use it) by providing some interesting functions. Have you tried
    print header, start_html(-head=>meta({-http_equiv => 'refresh', -content => "01; URL=http://eoinmurph +y00.netfirms.com/cgi-bin/albums.cgi?status=viewall&album=$album&user= +$user"}));
    yet?
    Cheers, CombatSquirrel.
    Entropy is the tendency of everything going to hell.
      That was it. Good man yourself. I never thought that the cgi.pm wouldn't support the html. I thought that it must have been a syntax\logic error i didn't spot.

      Thanks for every thing
      ++

      All the Best, Eoin...

      If everything seems to be going well, you obviously don't know what the hell is going on.

Re: upload errors
by Abigail-II (Bishop) on Aug 26, 2003 at 23:17 UTC
    The error message says:
    More information about this error may be available in the server error log.

    So, what did the error log say?

    Abigail

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://286885]
Approved by phydeauxarff
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-04-19 08:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found