RE: [PHP] Streaming a jpg
| From: | Matthew Loff | Date: | Sat, 11 Aug 2001 00:55:32 +0000 |
| Subject: | RE: [PHP] Streaming a jpg | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-62235@lists.php.net to get a copy of this message | ||
Todd--
Someone suggested readfile(), which I agree is even easier... Here's a
-very- basic sample:
In your HTML file...
<IMG SRC="image.php?filename=whatever.jpg">
In image.php:
<?php
header("Content-Type: image/jpeg");
readfile($filename);
?>
-----Original Message-----
From: Todd Cary [mailto:todd@aristesoftware.com]
Sent: Friday, August 10, 2001 6:54 PM
To: Matthew Loff
Cc: php-general@lists.php.net
Subject: Re: [PHP] Streaming a jpg
Matthew -
The following script just gives me a blank image holder. Am I missing
something simple?
Todd
<?php
header("Content-Type: image/jpeg");
$filename = "test.jpg";
$fd = fopen($filename, "r");
if ($fd) {
$contents = fread ($fd, filesize ($filename));
print($contents);
fclose($fd);
} else {
print("Cannot open file<br>");
}
?>
This works:
<?php
// Read a text file
$filename = "test.txt";
$fd = fopen($filename, "r");
if ($fd) {
$contents = fread ($fd, filesize ($filename));
print($contents);
fclose($fd);
} else {
print("Cannot open file<br>");
}
?>
--
Todd Cary
Ariste Software
todd@aristesoftware.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net To
contact the list administrators, e-mail: php-list-admin@lists.php.net