sulfericacid has asked for the wisdom of the Perl Monks concerning the following question:
One of my main questions is, which MIME type should be used? I read a few lists of them and none scream "BINARY" at me. Some of the APPLICATIONs look okay but there's dozens of MIME types to try and fail with, so which do you think I should be using?
And if something is wrong with my code (or if there's a better way to push the files to the user), I'd love to hear about it.
Thanks Monks!# $location is the absolute path to the known file on the server if ($download) { my $data = qq(SELECT id, fileloc, name, description FROM files WHE +RE 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 "<center><b>ERROR!</b> 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); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: opening a file for printing
by gaal (Parson) on Feb 16, 2005 at 17:42 UTC | |
|
Re: opening a file for printing
by friedo (Prior) on Feb 16, 2005 at 17:46 UTC | |
by sulfericacid (Deacon) on Feb 16, 2005 at 17:51 UTC | |
by friedo (Prior) on Feb 16, 2005 at 18:07 UTC | |
by sulfericacid (Deacon) on Feb 16, 2005 at 19:06 UTC | |
by friedo (Prior) on Feb 16, 2005 at 19:47 UTC |