简体   繁体   English

处理php时出错

[英]Error while processing the php

I'm working on a project and I want to display user profile dp on and image background when I'm testing my code on WAMP server its working fine and display things as i required with some error but when i try to test it with my server online then its does not show the image and also with and error of failed to open stream: Connection refused in online 我正在一个项目上,我想在WAMP服务器上测试我的代码时显示用户配置文件dp和图像背景,它可以正常工作并按我的要求显示某些错误,但是当我尝试用我的代码对其进行测试时服务器在线,则它不显示图像,并且还显示错误和无法打开流的错误:在线连接被拒绝

<?php 


    $text = 'Name';
    $t2 = '1594878934116599';

    $image_url="dump/".rawurldecode(trim($t2)).".jpg";
    $text = 'Name';

        $randomNumber = rand(1, 3);
        $im = imagecreatefromjpeg('img/' . $randomNumber . '.jpg');
copyImage($im, "https://graph.facebook.com/".$t2."/picture?width=200&height=200",  60, 80);
function copyImage($im, $dp1_name, $x1, $y1,$name,$g,$h){
                $dp1 = imagecreatefromjpeg($dp1_name);
                list($ow, $oh) = getimagesize($dp1_name);
                imagecopyresized($im, $dp1, $x1, $y1, 0, 0, 180, 180, $ow, $oh);
                            }


        $black = imagecolorallocate($im, 0, 0, 0);

        $font_path = 'LiberationSans-Bold.ttf';
        imagettftext($im, 20, 0, 8,39, $black, $font_path, $text);

        imagejpeg($im,$image_url);
        imagedestroy($im);


    ?>

I can confirm that following code is working just fine on my own local MAMP. 我可以确认以下代码在我自己的本地MAMP上工作正常。 I've removed some of the unused arguments from the copyImage() function, which caused warning messages. 我从copyImage()函数中删除了一些未使用的参数,这导致了警告消息。 And re-ordered the code a bit. 并重新排序了一下代码。 Added my own font and image but you could replace that again for your own. 添加了我自己的字体和图像,但是您可以自己替换它。 Try it out on your server. 在您的服务器上尝试一下。 And if it gives errors than please post the error here. 如果它提供了错误,请在此处发布错误。

<?php 

    function copyImage($im, $dp1_name, $x1, $y1){
        $dp1 = imagecreatefromjpeg($dp1_name);
        list($ow, $oh) = getimagesize($dp1_name);
        imagecopyresized($im, $dp1, $x1, $y1, 0, 0, 180, 180, $ow, $oh);
    }

    $text = 'Name';
    $t2 = '1594878934116599';

    $image_url="dump/".rawurldecode(trim($t2)).".jpg";
    $text = 'Here the name';

    $randomNumber = rand(1, 3);
    $im = imagecreatefromjpeg('penguin02.jpg');

    copyImage($im, "https://graph.facebook.com/".$t2."/picture?width=200&height=200",  60, 80);

    $black = imagecolorallocate($im, 0, 0, 0);

    $font_path = 'impact.ttf';
    imagettftext($im, 20, 0, 8,39, $black, $font_path, $text);

    imagejpeg($im,$image_url);
    imagedestroy($im);

    echo '<img src="'.$image_url.'">';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM