我有一个从文件夹中读取图片的JavaScript幻灯片,我需要从.dat文件中读取每个图片的描述。脚本是这样的:
<?php
require ('macoola.inc');
$upload = new images_upload('installations/', 3000000, 'info.dat');
$photo_list = $upload->read_data(); #this gets unserialized values from info.dat
#read all jpegs in the folder
$path_userspecific_array = explode(";", $_SESSION['userDirs']);
$images_splice = null;
settype($images_splice, "array");
foreach($path_userspecific_array as $thisdir){
$thispath = ('installations/' . $thisdir);
$thisimages = null;
$thisimages = glob($thispath.'/{*.jpg,*.JPG,*.jpeg,*.JPEG}', GLOB_BRACE);
$images_splice = array_merge($images_splice, $thisimages);
}
?>然后这里是java:
{
image: '<?php
echo $filename ?>',
title: '<?php
**#show description here**
?>',
thumb : '<?php echo $filename ?>'
}提前谢谢你。
发布于 2013-11-22 23:43:37
我终于解决了这个问题!解决方案非常简单。我没有使用另一个脚本读取文件夹中的图像,而是直接从.dat文件中提取图片和描述的链接,如以下代码所示:
<?php
require ('macoola.inc');
$upload = new images_upload('url/', 3000000, 'info.dat');
$photo_list = $upload->read_data();
$photo_url = "url/";
?>然后使用foreach函数打印我需要的字符串,将其放入Supersized中的“幻灯片”字段:
<?php
foreach ($photo_list as $key=>$val){
$input .= " image: '".$photo_url.$key."', title: '".$val['desc']."', thumb : '',";
?>
{ <?php echo $input; ?> },
<?php } ?> https://stackoverflow.com/questions/20128162
复制相似问题