RE: Displaying An Image / Non-Web accessible Dir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I would thing you could do something similar using the GD "image" functions,

http://www.php.net/manual/en/ref.image.php

in your html page code <img src="path/to/imagemodule.php"> and this module
would

basically;
	1. determine the type of image (jpec, gif, etc) (note you can pass ?parms
in get format to your imagemodule
	   in the src reference above)
	2. output the correct mime headers for that type of image
http://www.php.net/manual/en/function.header.php
		header('Content-type: image/jpeg');
		header('Content-Length: $len');
	3. $img = imagecreatefromxxx("/full/path/to/image/file.xxx") where xxx is
the type of image

	----- here you have an opportunity to do all kinds of things like resize
the image to a thumbnail, add text
            overlays, etc.

	4. imagexxx($img); where xxx is the type of image actually will output the
image behind the headers
	....that's all there is

If there are better PHP options, hopefully someone will provide them here.

Good Luck,

Warren Vail

-----Original Message-----
From: Armando [mailto:dijital@xxxxxxx]
Sent: Sunday, October 31, 2004 10:29 PM
To: PHP Windows List
Subject:  Displaying An Image / Non-Web accessible Dir


Greetings!

I'm porting all my old ASP websites to PHP and have run into a small
problem. One of my pages is a gallery in which images can (should) only
be viewed by authenticated users in my MySQL database. The images are
stored in a non-web accessible directory. For example.. say my root
website is in 'C:\www\webroot' and the gallery images are in
'C:\www\gallery'.

On my ASP page what I did was have the <img> tag call to an ASP page
which would open the file from the actual location on the disk, then
stream it to the page. ASP's filesystemobject and adodb stream
references open the file and do a binary-write to the page to display
the image. Since the page is ASCII and the image data is binary, you
cannot mix the two on the same page,  hence the reason for the <img> tag
calling to a separate ASP page.

Now my problem is I'd like to do the same thing in PHP but am not
exactly sure how to go about doing this. I've tried a number of the
filesystem references, but have had no luck so far. I'm assuming I have
to do a similar thing by having my <img> tag call to a PHP page to get
the image, which is easy enough, but I can't figure out how to display
the image from that page. I'm just not familiar enough with PHP yet to
do this.

Any help would be greatly appreciated! Cheers.

Armando

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux