# $location is the absolute path to the known file on the server if ($download) { my $data = qq(SELECT id, fileloc, name, description FROM files WHERE id = "$download"); $sth = $dbh->prepare($data); $sth->execute() or $dbh->errstr; my ($id, $location, $name, $desc); $sth->bind_columns(\$id,\$location,\$name,\$desc); if ($sth->rows < 1) { print "
ERROR! Your download key was not found."; exit; } else { # print special header here binmode( STDOUT ); open (FILE, "<$location") or die "Error opening file: $!"; my ($bytesread, $buffer); while ( $bytesread = read( $location, $buffer, 1024 ) ) { print $buffer; } close (FILE); } }