in reply to Uploading a file
gets the filename the user wants to upload from his local drive, and a file handle to said file. You then proceed to use a loopmy $fn = $html->param ('photofile'); my $fh = $html->upload ('photofile');
to read the data into a string. Now I perform some other processing on the file data before it's loaded into the database, but you could copy it straight to a file (I pump the image through ImageMagick to create a thumbnail, do some normalization, and limit the dimensions of the picture). You *absolutely* need to set a limit on how much data you'll accept or some weenie may try to upload a 1,000,000 x 1,000,000 x 24 bit image of Britney Spears to see how you'll handle it.# # This could get a little hairy. We don't know how big a picture +the user i # give us. We're going to limit him to 512K. That should cover a +nything we # of. # while ((length ($photo) <= (512 * 1024)) && read ($fh, $buffer, 102 +4)) { $photo .= $buffer; } if (length ($photo) == (512 * 1024)) { print_file ("File too big!"); return; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Uploading a file
by Anonymous Monk on Jun 08, 2000 at 17:06 UTC |