Re: how to show picture with php?
| From: | Mike Flynn | Date: | Mon, 23 Jul 2001 13:20:40 +0000 |
| Subject: | Re: how to show picture with php? | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-8450@lists.php.net to get a copy of this message | ||
Are they on the web server, i/e under the web root? If so, just show them as you would ANY picture in HTML.
$picture = '/path/to/picture/picture1.jpg';
$width = 100;
$height = 50;
echo "<img src=\"$picture\" width=\"$width\" height=\"$height\" border=\"0\" alt=\"My picture\">\n";
If they aren't then you will have to either move them to a folder under the web root, or do one of two workarounds: copy them to a temp file under the web root somewhere (which doesn't make much sense, because you will never really know when that file should be deleted), or extract them via PHP with a PHP script under your web root.
To extract them via a PHP page is a bit more difficult, but basically involves something like this..
<img src="/path/showpic.php?picname=picture1.jpg">
And have the script look something like this:
----showpic.php----
header("Content-Disposition: filename=$picname");
header("Content-Type: $file_type");
header("Content-Length: $file_size");
readfile("/hard_drive_path/to/file/$picname");
-------------------
That's a rough sketch.
But again, the easiest way to do it is just move the picture files onto somewhere on your web server and just access them like any picture, using the <img> tag and having PHP fill in the file name.
-Mike
At 12:28 PM 7/23/2001 +0200, Luká¹ Noskieviè wrote:
I have some pictures and i cannot find the way how to show them. I know the name and location of the picture (d:\pictures\picture1.jpg, picture2.jpg, ...) I want to show just one picture which name i send through web form. Can somebody help me? -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net For additional commands, e-mail: php-windows-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
-=- Mike Flynn - Burlington, VT -=-mike@mikeflynn.net http://www.mikeflynn.net/ * Give blood * American schoolchildren today are taking four times as many psychiatric meds as all of the rest of the world combined.