Re: How can I display an image within a script?

From: Date: Tue, 15 Jul 2003 22:08:02 +0000
Subject: Re: How can I display an image within a script?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-155320@lists.php.net to get a copy of this message
Hello, This is a reply to an e-mail that you wrote on Tue, 15 Jul 2003 at 21:14, lines prefixed by '>' were originally written by you. > Ok, assuming that the image files are outside the public web tree and > you can read them with a script. You will have to write a php script > that will read the file (sending the appropriate headers). > So your script will generate html like > <img src="/showimage.php?file=filename.jpg"> > then showimage.php will do something: > header('content-type: appropricate/type'); > // content-length would be good > readfile($file); My addition to this advice would be to make sure you do some sort of validation of $_GET['file'] before you use it within the readfile() function or you have a security problem. For example people could send a request for /showimage.php?file=yourscript.php and they would be presented with the source code to your PHP script. David. -- phpmachine :: The quick and easy to use service providing you with professionally developed PHP scripts :: http://www.phpmachine.com/ Professional Web Development by David Nicholson http://www.djnicholson.com/ QuizSender.com - How well do your friends actually know you? http://www.quizsender.com/ (developed entirely in PHP)

« previous php.general (#155320) next »