In the following code to write the contents of a file to a specified filename, the buffer size is given as 16_384 (from this node Re: File Upload - What Next?):
I've seen other numbers such as 1024 (1 kb). Is it an arbitrary number of bytes?use CGI: my $q = new CGI; use constant BUFFER_SIZE => 16_384; my $filename = $q->param( "filename" ) || die; # Assuming $filename is sanitized... my $fh = $q->upload( "file" ); my $buffer = ''; open(OUT,">/tmp/$filename"); binmode $fh; binmode OUTPUT; # Write contents to output file while ( read( $fh, $buffer, BUFFER_SIZE ) ) { print OUTPUT $buffer; }
Thanks in advance :)
In reply to Ideal buffer size.. by kiat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |