--- Janek Schleicher <[EMAIL PROTECTED]> wrote: > I'm also not an expert of uploading files. > But you do two things to read the file: > > $file = $q->param("file$i"); > Now $file contains a string. > > Then you use something like > my $uploaded = <$file>; > > So now you use $file as a Filehandle, > but in fact it's still a simple stupid string.
It would seem that way, but this is not the case. From the CGI.pm documentation: When the form is processed, you can retrieve the entered filename by calling param(): $filename = $query->param('uploaded_file'); [snip] The filename returned is also a file handle. You can read the contents of the file using standard Perl file reading calls: # Read a text file and print it out while (<$filename>) { print; } This has long been a convenience provided for by the CGI module. > > for some reason when, I do this it doesnt print any thing, it just makes the file. Offhand, I don't see anything wrong with the code. I have two questions: can you show us the HTML and are you using enctype="multipart/form-data" in your form tag? Here's a quick rewrite of how I would probably lay this out. There's still some more stuff that can be done here, but this should get you going. Feel free to ask "why" I did something the way that I did. use File::Basename; # later my $files_uploaded = uploadfiles( $q, \%user ); sub uploadfile { my ( $q, $user ) = @_; # localize $_ so we don't step on it outside of the block local $_; my $file_count = 0; for ( 1 .. 5 ) { if ( my $file = $q->param( "file$_" ) { my $filename = basename( $file ); open FILE, "> $user->{'site_id'}/$filename" or error(...); binmode $file; print FILE <$file>; $file_count++; } close FILE or die $!; } return $file_count; } Cheers, Curtis "Ovid" Poe ===== "Ovid" on http://www.perlmonks.org/ Someone asked me how to count to 10 in Perl: push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//; shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]