我正在创建我的第一个网站作为一个大学项目,我不是很先进,无论如何我有一个非常独特的问题。我的客户从谷歌驱动器发送了一堆 jpg 格式的图像。
我有一个 collection.php 文件,动态填充从 JSON 文件中获取的每个集合。
一切正常,除了图像的来源没有显示,如果我使用从互联网上下载的某些图像,那么它工作正常,
有趣的是所有那些不能用于 collection.php 的图像,当我在测试文件上执行时甚至不工作:localhost/test.html,
但是当我转到该文件夹并且只需双击 test.html 文件时,该文件将在浏览器中打开并显示以下 URL:file:///Users/ ****** /Sites/test.html 并且图像显示完全正常,最终我将尝试使用 godaddy 服务器,所以,如果它是一个服务器问题,我希望他们将在 godaddy 服务器上工作可能是什么问题?这是我的代码:
HTML/PHP:
//Get the collections_id from the query string and get the ranges which make up the collection from the database
$querystring = $_SERVER['QUERY_STRING'];
$splitQS = explode('=', $querystring);
$collectionReference = $splitQS[1];
$file = 'json/collectionSlides_' . $collectionReference . '.json';
//Find get and loop through JSON data which has details about collection range sliders
$collFile = file_get_contents($file);
$collection = json_decode($collFile);
for ($i=0; $i < count($collection->Collection); $i++) {
$collectionDisplay[$i] = array(
'id' => $collection->Collection[$i]->range_id,
'heading' => $collection->Collection[$i]->heading,
'image1' => $collection->Collection[$i]->slide1,
'image2' => $collection->Collection[$i]->slide2,
'image3' => $collection->Collection[$i]->slide3,
'image4' => $collection->Collection[$i]->slide4,
);
}
JSON:{
"Collection":[
{
"range_id":1,
"heading":"Pheonix",
"slide1":"keyholebraandknickers2.jpg",
"slide2":"wiredbrawithknickers2.jpg",
"slide3":"wiredbrawithknickers3.jpg",
"slide4":"xbraandsuspenderthong1.jpg"
},
{
"range_id":2,
"heading":"Sophia",
"slide1":"keyholecrossoverbraletandknickers1.jpg",
"slide2":"keyholecrossoverbraletandknickers3.jpg",
"slide3":"keyholecroptopandbriefs1.jpg",
"slide4":"bustierandbriefs1.jpg"
},
{
"range_id":3,
"heading":"Lily",
"slide1":"deepvbody2.jpg",
"slide2":"braletandlacemeupbriefs1.jpg",
"slide3":"pleatedwiredbraandbriefs4.jpg",
"slide4":"deepvbody3.jpg"
},
{
"range_id":4,
"heading":"Pearl",
"slide1":"croptopandbriefs4.jpg",
"slide2":"croptopandbriefs2.jpg",
"slide3":"halftrianglecupbody3.jpg",
"slide4":"wiredbody2.jpg"
}
]
}
?>
CSS:
#collWrap{
display: grid;
padding: 0.83em;
grid-template-columns: repeat(2, 1fr);/*Currently set up for 2 in one
line, 4 seems too cramped */
grid-column-gap: 0.83em;
border: 0.08em solid red;
}
.collFrac{
border: 0.08em solid blue;
padding: 0.83em;
margin: 0.83em;
}
.collFrac h3{
text-align: center;
margin-bottom: 0.5em;
font-size: 2em;
font-weight: lighter;
border-top: 0.08em solid #ffffff;
border-bottom: 0.08em solid #ffffff;
}
.collFrac img{
width: 100%;
display: block;
height: auto;
}
Vardump 结果:
array(4){[7] => array(6){[8] => int(1)[9] => string(7)“Pheonix”[10] => string(26)“keyholebraandknickers2.jpg”[11] => string(25)“wiredbrawithknickers2.jpg”[12] => string(25)“wiredbrawithknickers3.jpg”[13] => string(26)“xbraandsuspenderthong1.jpg”} [14] => array(6){[15] => int(2)[16] => string(6)“索菲亚”[17] => string(38 )“keyholecrossoverbraletandknickers1.jpg”[18] => string(38)“keyholecrossoverbraletandknickers3.jpg”[19] => string(28)“keyholecroptopandbriefs1.jpg”[20] => string(21)“bustierandbriefs1.jpg”} [21] => array(6){[22] => int(3) [23] => string(4)“Lily”[24] => string(14)“deepvbody2.jpg”[25] => string(28)“braletandlacemeupbriefs1.jpg”[26] => string(29)“pleatedwiredbraandbriefs4.jpg”[27] => string(14)“deepvbody3.jpg” } [28] => array(6){[29] => int(4)[30] => string(5)“珍珠”[31] => string(21)“croptopandbriefs4.jpg”[32] => string(21)“croptopandbriefs2.jpg”[33] = > string(24)“halftrianglecupbody3.jpg”[34] => string(14)“wiredbody2.jpg”}}