开发者

storing avatar on user creation

I have a random image generated by php (monsterid) and I want to store it on my server upon user registration, but the following gives me an error:

$url = 'http://www.example.com/admin/monsterid/monsterid.php';
$monsterimg = '/admin/monsterid/monsters/'.$timestamp.rand(0,999).'.png';
file_put_contents($mons开发者_开发技巧terimg, file_get_contents($url));

Error =

Warning: file_put_contents(/admin/monsterid/monsters/efefef990.png) [function.file-put-contents]: failed to open stream: No such file or directory in /home/example/public_html/admin/register.php on line 35


Give the full path here

$monsterimg = '/some/path/admin/monsterid/monsters/'.$timestamp.rand(0,999).'.png';


You have a problem with the path to where the image will be saved. Try using realpath() and dirname()


define('APPLICATION_PATH, realpath(dirname(__FILE__)));

$monsterimg = APPLICATION_PATH . '/admin/monsterid/monsters/'.$timestamp.rand(0,999).'.png';

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜