IMG SRC PHP -> PNG

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Pazuzu156
Forum Contributor
Posts: 241
Joined: Sat Nov 20, 2010 9:00 pm
Location: GA, USA
Contact:

IMG SRC PHP -> PNG

Post 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?
- Kaleb Klein
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
gooney0
Forum Commoner
Posts: 56
Joined: Fri Jan 21, 2011 1:40 pm
Location: Reston, VA

Re: IMG SRC PHP -> PNG

Post 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>
User avatar
Pazuzu156
Forum Contributor
Posts: 241
Joined: Sat Nov 20, 2010 9:00 pm
Location: GA, USA
Contact:

Re: IMG SRC PHP -> PNG

Post by Pazuzu156 »

How would I use that to map captcha.png to the php file?
- Kaleb Klein
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
User avatar
phazorRise
Forum Contributor
Posts: 134
Joined: Mon Dec 27, 2010 7:58 am

Re: IMG SRC PHP -> PNG

Post 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.
User avatar
phazorRise
Forum Contributor
Posts: 134
Joined: Mon Dec 27, 2010 7:58 am

Re: IMG SRC PHP -> PNG

Post 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.
Post Reply