获取图像保存的问题 [英] Problem getting image to save

查看:76
本文介绍了获取图像保存的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用php动态创建图像。如果我进入并首先制作文件,则会创建图像。但是,如果我不手动创建文件,则会出现以下错误。

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.

警告:imagegif()[function.imagegif]:无法打开'filename2。 png'用于写入第144行的/www/vhosts/yourraceresults.com/htdocs/trial/TextToImage.inc.php

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

示例:

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');

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

推荐答案

输出文件夹不存在(在这种情况下你必须创建它),或者你没有对输出文件夹的写权限。解决此问题:

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:


  • 如果您使用的是shell:

  • If you're using a shell:

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

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

如果您使用的是FTP客户端:

If you're using an FTP client:

右键单击试用文件夹,搜索名为chmod,rights,permissions(可能在属性中)的内容,然后给予每个权限,或者输入chmod值777。

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.

这篇关于获取图像保存的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆