我有一個圖像的文件夾,我希望用PHP加載到圖像列表中,可以使用可排序的jQueryUI功能移動。我跑了一個基本的PHP測試,所以我知道PHP沒有失敗,但是我的代碼可能由於其他原因而錯誤,並且我對jQueryUI的使用經驗不足。以下是我希望使用的代碼的重要部分。尋找一種方式來使用'可排序'功能與PHP
<script type="text/javascript" src="jquery-1.9.1.js"></script>
<script type="text/javascript" src="jquery-ui-1.10.1.custom.min.js"></script>
<script language="javascript" type="text/javascript" defer>
jQuery(document).ready(function($) {
$("#item-wrap").sortable();
$("#item-wrap").disableSelection();
});
</script>
<style>
#item-wrap { list-style-type: none; margin: 0; padding: 0; width: 450px; }
#item-wrap li { margin: 3px 3px 3px 0; padding: 1px; float: left; width: 300px;
height: 300px; font-size: 4em; text-align: center; }
</style>
<ul id="item-wrap">
<?php
$imagesDir = '/uploads/gallery1/';
$images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
$imglist = json_encode($images);
for ($i = 1; $i <= count($imglist); $i++) {
?><li><?php
echo $array[$i];
?></li><?php
}
</ul>
?>
圖像無法顯示,也沒有創建列表。 任何幫助或建議,非常感謝。
歡迎計算器。你會詳細說明什麼是真正的失敗? – 2013-03-06 12:39:49
你真的有/ uploads/gallery1 /文件夾嗎?或者你的意思是相對路徑,「uploads/gallery1 /」? – Stormherz 2013-03-06 12:41:00
不加載圖像,並且不生成列表。爲了迴應Stormherz,這條道路是相對的。 – user2126833 2013-03-06 13:22:22