Page 1 of 1

IMG SRC PHP -> PNG

Posted: Sun Jul 10, 2011 12:21 pm
by Pazuzu156
I know the title doesn't explain a lot, but here it goes. I an working with a captcha thing, and when I use the src attribute, instead of using captcha.php i want it to be captcha.png. Any way to make this possible?

Re: IMG SRC PHP -> PNG

Posted: Sun Jul 10, 2011 1:08 pm
by gooney0
Yes though you'd need to tell the web server than captcha.png is actually a PHP file and should be processed as such.

If you're using Apache you can do this with a .htaccess file something like:


<FilesMatch "^captcha.png$">
ForceType application/x-httpd-php
AcceptPathInfo On
</FilesMatch>

Re: IMG SRC PHP -> PNG

Posted: Sun Jul 10, 2011 1:09 pm
by Pazuzu156
How would I use that to map captcha.png to the php file?

Re: IMG SRC PHP -> PNG

Posted: Sun Jul 10, 2011 1:19 pm
by phazorRise
yes, you can do that with editing/including .htaccess file in that particular directory.
But you need to edit it for that purpose.
Although, i guess/suggest you do it with traditional way (you've mentionem) because when you use .htaccess, it causes overhead on server searching each directory for .htaccess file.

Re: IMG SRC PHP -> PNG

Posted: Sun Jul 10, 2011 1:22 pm
by phazorRise
Pazuzu156 wrote:How would I use that to map captcha.png to the php file?
You don't need to worry about that. Server will take care of it with .htaccess file.