Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am creating an image dynamically using php. The image is being created if I go in and make the file first. However, if I don't create the file manually then I get the following error.

Warning: imagegif() [function.imagegif]: Unable to open 'filename2.png' for writing in /www/vhosts/yourraceresults.com/htdocs/trial/TextToImage.inc.php on line 144

Example:

public function SaveTextAsPng($fontSize, $x, $y, $textContent, $fileName='image'){
    imagestring($this->image, $fontSize, $x, $y,  $textContent, $this->text_color);
    return imagepng($this->image, "/www/vhosts/yourraceresults.com/htdocs/admin/trial/images/".$fileName.".png");
}

$textToImage->SaveTextAsPng(10, 11,11, 'fakeinfo','filename2');

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
714 views
Welcome To Ask or Share your Answers For Others

1 Answer

Either the output folder do not exist (in which case you have to create it), or you do not have write permissions to the output folder. To fix this:

  • If you're using a shell:

    chmod 777 /www/vhosts/yourraceresults.com/htdocs/trial

  • If you're using an FTP client:

    Right click on the "trial" folder, search for something called "chmod", "rights", "permissions" (perhaps in "properties"), then give it every permission or, alternatively, enter chmod value 777.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...