Jump to content

PHP Image Creating


mart94

Recommended Posts

Hi, i searched form internet "Image creating" script, i found one and this is working great, but is it possible to give this file name like picture.png to use it forum avatar.

 

PHP Code:

<?php

$my_img = imagecreate( 130, 130 );

$background = imagecolorallocate( $my_img, 255, 255, 255 );

$font  = 'Bedizen.ttf';

$text = "Kell On:";

$size = 11;

$text_color = imagecolorallocate( $my_img, 0, 0, 255 );
$text_color2 = imagecolorallocate( $my_img, 255, 0, 0 );

$date = date("G:i:s");

imagesetthickness ( $my_img, 5 );

imagettftext($my_img, $size, 4, 40, 50, $text_color, $font, $text); 
imagettftext($my_img, $size, 4, 35, 65, $text_color2, $font, $date); 

header( "Content-type: image/png" );
imagepng( $my_img );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $my_img ); 

?>

 

www.xcsx.eu/test2.php

 

All the best:

Mart

Link to comment
https://forums.phpfreaks.com/topic/183053-php-image-creating/
Share on other sites

Creating a .htaccess file with this in it and putting it in the same directory should work.

 

<Files "picture.png">
AddType application/x-httpd-php .png
</Files>

 

Just rename your php script "picture.png", and the code above should enable picture.png to be parsed as a php file.

Link to comment
https://forums.phpfreaks.com/topic/183053-php-image-creating/#findComment-966112
Share on other sites

You can send a PNG image from PHP by changing the header to 

<?php
header("Content-Type: image/x-png");

 

That tells the browser its an PNG image.  The actual File extension  .php , .png, jpg etc, really are meaningless.

Its the header that matter.

 

Edit, I see you already have that. :examine: Well I guess you can do what AlexWD says. Is the forum  your trying to put php image not allowing .php ext in the image name? Its kinda stupid though. Since the ext, as I said is meaningless, specially if you can just change the .png to served as php on the server with that .htaccess, it just shows you how flawed such "restrictions" are. They fail.  :D

 

 

Most forum dont' except images from externals sources, I imagine it would be easy to server up a Javascript threw a supposed image, then do XSS somehow with the image tag.  :keep_quiet:

Link to comment
https://forums.phpfreaks.com/topic/183053-php-image-creating/#findComment-966244
Share on other sites

Creating a .htaccess file with this in it and putting it in the same directory should work.

 

<Files "picture.png">
AddType application/x-httpd-php .png
</Files>

 

Just rename your php script "picture.png", and the code above should enable picture.png to be parsed as a php file.

 

Doesn't work, maybe it's mine mistake but now renamed php script "picture.png" will start download, and can't be dispalyed...

Link to comment
https://forums.phpfreaks.com/topic/183053-php-image-creating/#findComment-966285
Share on other sites

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.