Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.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
(PHP)显示动态目录中的图像_Php_Xml_Image_Xhtml - Fatal编程技术网

(PHP)显示动态目录中的图像

(PHP)显示动态目录中的图像,php,xml,image,xhtml,Php,Xml,Image,Xhtml,在一台服务器上,我成功地编写了映像,如下所示: $structure = "./images/$root->City/$root->ZipCode/$root->StreetDirection $root->StreetName/"; file_put_contents("./$structure/$root->StreetNumber $root->StreetDirection $root->StreetName $root->StreetS

在一台服务器上,我成功地编写了映像,如下所示:

$structure = "./images/$root->City/$root->ZipCode/$root->StreetDirection $root->StreetName/";

file_put_contents("./$structure/$root->StreetNumber $root->StreetDirection $root->StreetName $root->StreetSuffix $root->City $root->ZipCode-{$number}.jpeg", $photo['Data']);
然后,我尝试检索并显示相同的图像相同的位置,如下所示,什么也没有发生(断开的图像链接):

$structure=“../images/$City\u R/$Zip\u code\R/$StreetDirection$StreetName$StreetSuffix/$StreetNumber$StreetDirection$StreetName$StreetSuffix$City\R$Zip\u code\R-1”;
$img='
'; 回音“$img”;

在测试中,它似乎只在名称大大简化且未指定动态目录时才进行拉取…,实际上,它会一起忽略目录…

我不会以这种方式构建src属性。我会在引号外构建它,因为在插入变量值时处理引号内的空格会变得不必要的复杂。 只需在字符串外部使用连接运算符:

$structure = "../images/" . $City_R . "/" . $Zip_Code_R . "/" . $StreetDirection . $StreetName . $StreetSuffix . "/" . $StreetNumber . $StreetDirection . $StreetName . $StreetSuffix . $City_R . $Zip_Code_R-1;

//etc...
注意,您需要为图像源使用URL,并且使用路径。您的src属性最好以“”开头


不要在文件名中使用空格,而要使用破折号,破折号还有一个额外的好处,那就是它对搜索引擎优化也有好处:)

可能您使用的是路径,而您需要为img srchechoing“$img”提供一个url?无聊的?我是唯一一个觉得有趣的人吗?
$structure = "../images/" . $City_R . "/" . $Zip_Code_R . "/" . $StreetDirection . $StreetName . $StreetSuffix . "/" . $StreetNumber . $StreetDirection . $StreetName . $StreetSuffix . $City_R . $Zip_Code_R-1;

//etc...