in reply to CGI File upload, resulting files 0 bytes long

the code looks alright. but you didn't include the code that gave you the $data filehandle. be sure that $data was retrieved something like so:

my $data = $query->param("uploadfileTagname");

a common gotcha is opening the uploaded filehandle for read, then trying to write it back out. at least it "got" me....once :-)

Replies are listed 'Best First'.
Re: Re: CGI File upload, resulting files 0 bytes long
by Mandor (Pilgrim) on Mar 07, 2001 at 02:35 UTC
    I get my $data like this my $data        = $cgi -> param ( 'data' );
    Give it to my subroutine like this &receive_upload ( $data );
    And receive the value in my subroutine like this my $data = shift;

      from perlfaq5...

      For passing filehandles to functions, the easiest way is to preface them with a star, as in func(*STDIN). See the section on Passing Filehandles in the perlfaq7 manpage for details.

      from perlfaq7...

      How can I pass/return a {Function, FileHandle, Array, Hash, Method, Regexp}?
      With the exception of regexps, you need to pass references to these objects. See the section on Pass by Reference in the perlsub manpage for this particular question, and the perlref manpage for information on references.