Gruzin Posted April 2, 2007 Share Posted April 2, 2007 Hey guys, I have a little security code and it works just fine on windows, but on linux it doesn't creat a new PNG file. here is the code: <?php function SecurityCode(){ $num = rand(1000,9999); header ("Content-type: image/png"); $img_handle = imagecreate (50, 20) or die ("Cannot Create image"); $back_color = imagecolorallocate ($img_handle, 255, 255, 255); $txt_color = imagecolorallocate ($img_handle, 233, 114, 191); imagestring ($img_handle, 31, 7, 2, $num, $txt_color); imagepng ($img_handle,"code.png"); echo "<img src='code.png'>"; } ?> Any help will be greatly appreciated, George Link to comment https://forums.phpfreaks.com/topic/45236-solved-problem-with-gd-on-linux-2/ Share on other sites More sharing options...
MadTechie Posted April 2, 2007 Share Posted April 2, 2007 erm.. either remove the header or read the file inn, this works fine <?php function SecurityCode(){ $num = rand(1000,9999); //header ("Content-type: image/png"); $img_handle = imagecreate (50, 20); $back_color = imagecolorallocate ($img_handle, 255, 255, 255); $txt_color = imagecolorallocate ($img_handle, 233, 114, 191); imagestring ($img_handle, 31, 7, 2, $num, $txt_color); imagepng ($img_handle,"code.png"); echo "<img src='code.png'>"; } SecurityCode(); ?> also check you can write to that folder (as i had to update my access rights) Link to comment https://forums.phpfreaks.com/topic/45236-solved-problem-with-gd-on-linux-2/#findComment-219622 Share on other sites More sharing options...
Gruzin Posted April 2, 2007 Author Share Posted April 2, 2007 Thanks MadTechie, I've tried it but without no luck, I've added 'Die' function to imagepng and I recieve that error... Think I have to talk to my host about permissions. <?php function SecurityCode(){ $num = rand(1000,9999); //header ("Content-type: image/png"); $img_handle = imagecreate (50, 20) or die ("Cannot Create image"); $back_color = imagecolorallocate ($img_handle, 255, 255, 255); $txt_color = imagecolorallocate ($img_handle, 233, 114, 191); imagestring ($img_handle, 31, 7, 2, $num, $txt_color); imagepng ($img_handle,"images/code.png") or die("Cannot save image"); echo "<img src='images/code.png'>"; } ?> Link to comment https://forums.phpfreaks.com/topic/45236-solved-problem-with-gd-on-linux-2/#findComment-219629 Share on other sites More sharing options...
MadTechie Posted April 2, 2007 Share Posted April 2, 2007 i removed the header and die for testing (something get a few hint when removing them) have you checked the GD lib is installed ? does it create the code.png file ? phpinfo(); Link to comment https://forums.phpfreaks.com/topic/45236-solved-problem-with-gd-on-linux-2/#findComment-219631 Share on other sites More sharing options...
Gruzin Posted April 2, 2007 Author Share Posted April 2, 2007 i removed the header and die for testing (something get a few hint when removing them) have you checked the GD lib is installed ? does it create the code.png file ? phpinfo(); 1. Yes, I've checked phpinfo and it is installed (It does creat an image, but doesn't actually save it in directory). 2. No, it doesn't creat a png file (that's my problem). Thanks again, George Link to comment https://forums.phpfreaks.com/topic/45236-solved-problem-with-gd-on-linux-2/#findComment-219636 Share on other sites More sharing options...
MadTechie Posted April 2, 2007 Share Posted April 2, 2007 maybe try a quick <?php $your_data = "does it write to a text file."; $fp = fopen("test.txt", "w"); fwrite($fp, $your_data); fclose($fp); ?> Link to comment https://forums.phpfreaks.com/topic/45236-solved-problem-with-gd-on-linux-2/#findComment-219638 Share on other sites More sharing options...
Gruzin Posted April 2, 2007 Author Share Posted April 2, 2007 Thanks MadTechie, I've figured it out... permissions p.s How can I set this topic to solved? George Link to comment https://forums.phpfreaks.com/topic/45236-solved-problem-with-gd-on-linux-2/#findComment-219641 Share on other sites More sharing options...
MadTechie Posted April 2, 2007 Share Posted April 2, 2007 on the viewing of this post at the very bottom on the right you "should" see a solved button if you don't then just add post saying solved. the Solved mod works most of the time.. Link to comment https://forums.phpfreaks.com/topic/45236-solved-problem-with-gd-on-linux-2/#findComment-219644 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.