我有一个由php (monsterid)生成的随机图像,我想在用户注册时将其存储在我的服务器上,但以下代码给了我一个错误:
$url = 'http://www.example.com/admin/monsterid/monsterid.php';
$monsterimg = '/admin/monsterid/monsters/'.$timestamp.rand(0,999).'.png';
file_put_contents($monsterimg, file_get_contents($url));错误=
警告: file_put_contents(/admin/monsterid/monsters/efefef990.png)函数.file-put-contents:无法打开流:第35行的/home/example/public_html/admin/register.php中没有这样的文件或目录
发布于 2011-03-24 15:36:12
请在此处提供完整路径
$monsterimg = '/some/path/admin/monsterid/monsters/'.$timestamp.rand(0,999).'.png';发布于 2011-03-24 15:36:41
保存图像的路径有问题。尝试使用realpath()和dirname()
发布于 2011-03-24 16:31:57
define('APPLICATION_PATH, realpath(dirname(__FILE__)));
$monsterimg = APPLICATION_PATH . '/admin/monsterid/monsters/'.$timestamp.rand(0,999).'.png';
https://stackoverflow.com/questions/5416069
复制相似问题