in reply to Re: Cgi UpDATE
in thread Cgi Upload
You also seem to be unsure of the hash syntax; you don't need single quotes for constants: e.g.for ($loop=1; $loop <= $form{'files'}; $loop++){ if ($form{"img$loop"}){ print STDERR "in if: form var img${loop} is $form{img${loop}}\n" if $debug > 15; ... print STDERR "done mussing: form1 img$loop is $form1{img${loop}}\n" if $debug > 10; print STDERR "opening: form filename is $form{filename}\n" if $debug > 20; open(FILE, ">$form{'filename'}/$form1{\"img$loop\"}") or die "can't open ", "$form{filename}/$form1{img${loop}}", ": $!"; while ($bytesread=read($file,$buffer,1024)) { print STDERR "while: read $bytesread\n" if $debug > 20;
Doesn't cost you anything, code is more readable and its easier to use/debug, just print $this_loop or:my $this_loop = "img${loop}"; $hash{$this_loop} = ...
Do this, look through the error log and then you can confidently say 'its not working' ... probably, though, you'll see something useful in there. Oh, if its a busy server, prefix all the print STDERR msgs w/ "my_cgi: ..." so they'll stand out in the log. And when it works, my $debug = 0 makes them all go away.my $img_file = "$form{filename}/$form1{$this_loop}"; open(FILE, ">$img_file") or die "can't open $img_file: $!";
Update:Are you using (and if no, why not!? ;-) cgi.pm? It does the upload for you (search on cgi upload sysread) if you're using the upload stuff, so sysread won't find anything to ... well read. 'course, that means all that debugging would be for naught, but still its good practice. Sort of that "set a monk on fire" idea (hmm, bad connotations there, sorry).
a
|
---|