Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从getphp返回图像_Php_Echo - Fatal编程技术网

从getphp返回图像

从getphp返回图像,php,echo,Php,Echo,我知道这听起来可能很愚蠢,但我试着回显一张图片,我从url中得到他的名字,我什么都没有,只有图片的alt文本 这是我的密码 <?php $url = $_GET["userpic"]; $DisplayImg = "./Imagenes/".$url.".jpg"; ?> <html> <body> <img src="<?php echo $DisplayImg; ?>" alt="Error" width="100%" height=

我知道这听起来可能很愚蠢,但我试着回显一张图片,我从url中得到他的名字,我什么都没有,只有图片的alt文本

这是我的密码

<?php
$url =  $_GET["userpic"];
$DisplayImg = "./Imagenes/".$url.".jpg";
?>
<html>
<body>

<img src="<?php echo $DisplayImg; ?>" alt="Error" width="100%" height="100%" border="0" /> 
</body>
</html>
试试这个:

<html>
<body>
<img src="../Imagenes/<?php echo $_GET["userpic"]; ?>.jpg" alt="Error" width="100%" height="100%" border="0" /> 
</body>
</html>
如果这仍然不起作用,那么您的路径是错误的,您可以通过添加

<?php echo "<a href='../Imagenes/".$_GET["userpic"].".jpg'>this should link to your image</a>"; ?>
但丁

将扩展名改为.php而不是.html


如果要将php代码运行到.html中,请参阅

,您需要给出图像所在位置的完整路径吗?和var_dump;-2个可供您使用的宝贵工具。如果您获取了alt文本,则您的src url不正确,并且浏览器正在获取404。输出是什么?或检查图像src$DisplayImg=./images/'.$url..jpg;我想你需要一个额外的。$url。谢谢,我有一个html,因为我用谷歌图表javascript和其他东西制作东西,因为我是新手,我不知道我可以在一个php文件中制作所有东西,非常感谢你