mart94 Posted November 26, 2009 Share Posted November 26, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/183053-php-image-creating/ Share on other sites More sharing options...
Alex Posted November 26, 2009 Share Posted November 26, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/183053-php-image-creating/#findComment-966112 Share on other sites More sharing options...
keldorn Posted November 27, 2009 Share Posted November 27, 2009 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. 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. 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. Quote Link to comment https://forums.phpfreaks.com/topic/183053-php-image-creating/#findComment-966244 Share on other sites More sharing options...
mart94 Posted November 27, 2009 Author Share Posted November 27, 2009 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... Quote Link to comment https://forums.phpfreaks.com/topic/183053-php-image-creating/#findComment-966285 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.