Hytham Shehab wrote:
>
> hi gurus,
> i use the upload() function in the CGI module to get a file in the
> filefield tag, but i don't understand how to get it to the server?
> $fh=$q->upload('file_to_be_uploaded');
> while(<$fh>){
> print;
> }
you need to tell perl to print the uploaded file to a file on the hard
drive:
open(FILE, ">/some/directory/filename.ext");
my $fh = $q->upload('form_name_for_file_upload');
while (<$fh>) {
print FILE;
}
close(FILE);
don't forget that the file upload will fail if you try to overwrite a
file that already exists. also notice this code assumes $fh is a valid
filehandle (ie.- there's no code there to handle the case when it
isn't).