Jump to content

Need some help with using PHP module with .gif file formats


slpctrl

Recommended Posts

Alright, I've got this simple little script here:

 

<?php
//draws the image and stuff. . .
$im = @imagecreatefrompng( "babe.png" );
header( "Content-type: image/png" );
imagepng($im);
imagedestroy($im);
?>

This works fine when it's saved as a .php, but when I save it as a .gif file (and this is my .htaccess:

AddHandler application/x-httpd-php .png

)

So, it should parse .php even with the .gif extension, but as a .php file it works fine, just as it should but as a .gif file it says can not display this image because it contains errors.  

with your .htaccess do this..

 

RewriteRule ^/babe.gif$ thePHPFile.php

 

btw you're outputting as a png.. your addhandler is setting .png as an extension.. not .gif.. but either way that is a very bad idea to make images evaluate as php code

 

just make rewrite rules.. the above rewrite will when a user requests xxx.com/babe.gif it will redirect them to thePHPFile.php.. and the php can spit out the image.. then the user will think they're seeing an image.. but its rly a php generated image.. clever huh?! :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.