in reply to File source from memory
First, beware that different browsers send file name differently, if you expect to use that file name. IE sends full file path while Opera sends just the basename of file. And if you want your file saved on host use something like
my $file_name = CGI::param('file_field'); $file_name =~ s:^.*[\\/](.*)$:$1:; # remove path if present my $fh = CGI::upload('file_field'); if ( $fh ) { open(OUT, '>', "/dir/to/save/$file_name"); while (<$fh>) { print OUT $_; } close OUT; } else { # handle the error }
If you don't need the file name you may don't bother about it's correctness and just read from filehandle (which is $fh - the value that CGI::upload gives you) and send file data to whatever destination you need.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: File source from memory
by Anonymous Monk on Feb 18, 2005 at 19:16 UTC | |
by zentara (Cardinal) on Feb 19, 2005 at 13:27 UTC |