Jump to content

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


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?! :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.