Here's one I wrote as part of my content management system so users only get here after signing onto their accounts, and the files are uploading to their own site.


# upload a file from a user


sub upload
{
my($fl,$nam) = @_; # upload file & store name
open(OUT,">$nam") or &errMsg("Can't open $nam for writing");
binmode OUT;
my($blen,$bfr,$flen) = 1024;
while(read($fl,$bfr,$blen))
{
print OUT $bfr;
(++$flen > 1024) and # one megabyte limit on uploads
do { close(OUT); &errMsg('File too large. Save aborted.') }
}
close OUT or &errMsg("Can't close output file $nam");
}



If you can test on your own lan first I suggest it. Also note that in the while loop there is a test for size exceeding a limit which you can adjust to your needs. This is a fail safe highly recommended so your site's disk quota isn't exceeded.


BTW a simple security wrapper can be implemented using .htaccess on Apache servers. At minimum you should do that, imho. Unless you're setting up a truly public upload site.

hth,

Marty Landman   Face 2 Interface Inc 845-679-9387
This Month's New Quiz --- Past Superbowl Winners
Make a Website: http://face2interface.com/Home/Demo.shtml


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Reply via email to