开发者

storing avatar on user creation

开发者 https://www.devze.com 2023-02-19 04:41 出处:网络
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:

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

精彩评论

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

关注公众号