| Versionen | |
|---|---|
| drupal6 – drupal7 | file_transfer($source, $headers) |
Transfer file using HTTP to client. Pipes a file through Drupal to the client.
$source String specifying the file path to transfer.
$headers An array of HTTP headers to send along with file.
includes/
<?php
function file_transfer($source, $headers) {
if (ob_get_level()) {
ob_end_clean();
}
foreach ($headers as $name => $value) {
drupal_set_header($name, $value);
}
drupal_send_headers();
$source = file_create_path($source);
// Transfer file in 1024 byte chunks to save memory usage.
if ($fd = fopen($source, 'rb')) {
while (!feof($fd)) {
print fread($fd, 1024);
}
fclose($fd);
}
else {
drupal_not_found();
}
exit();
}
?>
Kommentare
Kommentar hinzufügen