in reply to use CGI vs use CGI qw(:standard)

I am not sure about #1 ... i wish i had time to look into it, but i have other work to do. #2, however is simply not true. Here is code that works for me:

use CGI qw(:standard); use File::Basename; my $PATH = '/path/to/dir/to/store/files'; if (param('go')) { my $handle = upload('the_file'); my $name = param('the_file'); fileparse_set_fstype('MSDOS') if $name =~ /\\/; $name = basename($name); open OUT, '>', "$PATH/$name" or die "can't open file $name: $!"; print OUT while <$handle>; }
Hope this helps ...

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: Re: use CGI vs use CGI qw(:standard)
by kiat (Vicar) on Apr 19, 2004 at 15:08 UTC
    Thanks, jeffa!

    You're right, (2) is not true. I commented out that particular line and it still works. But it's puzzling because the first time I commented it out, the image didn't show on the web page. It only showed on sebsequent uploadings.

    I had been running the code without that 'open(FH, $file)' line and I swore it didn't work for almost an hour when I was at it. I double-checked the folder where it was supposed to go to and although the file was created, the image wasn't properly saved. That was when I added the 'open(FH, $file)' line and then the image was rightly created, which puzzled me.