doujie4344 2012-05-10 16:55
浏览 91
已采纳

PHP和SWF - 幻灯片放映不显示

I am trying to display a slideshow. slide_auto.php is in the same directory as my slideS_img folder

Here is my slide_auto.php file:

<?php
$file_dir="slideS_img"; //change this to a folder name
$show_titles=false; //change to false if you don't want to see the captions
$omit_chars=0; //how many characters to cut off the title's front
$link_to_image=false; //do you want to display links?

print '<?xml version="1.0" encoding="iso-8859-1"?>
<slideshow  displayTime="5" 
            transitionSpeed=".7"
            ...more code...
            >';

            $dir=opendir($file_dir);
        $xml_string= array();
            while ($file=readdir($dir))
            {
                if(substr($file, -3) == "jpg" || substr($file, -4) == "jpeg" ){
                $tmp_str = '<image img="'.$file_dir.'/'.$file.'" ';
                if($show_titles){
                    $file_title=substr($file, $omit_chars, strpos($file, ".")-$omit_chars);
                    $tmp_str .= 'caption="'.$file_title.'" ';

                }

                if($link_to_image){
                    $link_title=substr($file, $omit_chars, strpos($file, ".")-$omit_chars);
                    $tmp_str .= 'link="'.$file_dir.'/'.$file.'" target="_blank"';

                }

                    $tmp_str .=" />";
                    array_push($xml_string, $tmp_str);
                }


            }
            sort($xml_string);
            for($i=0; $i<count($xml_string); $i++){
            print $xml_string[$i];
            }
closedir($dir);
print '</slideshow>';
?>

amd my slideshowpage.php:

<?php
require_once('slideshow/slide_auto.php')
?>

<!DOCTYPE>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>

<body>
<div align="center">
<br />
<br />
<br />
<div id="flashcontent">
  This text is replaced by the Flash movie.
</div>

<script type="text/javascript">
   swfobject.embedSWF("slideshow.swf?file=slideshow/slide_auto.php", "gallery", "100%", "100%", "7", "#333333");
   so.write("flashcontent");
</script>
</div>
</body>
</html>

I get an error saying Warning: opendir(slideS_img) [function.opendir]: failed to open dir: No such file or directory in /[path]/slideshow/slide_auto.php on line 62

Any help? Thank you

  • 写回答

2条回答 默认 最新

  • duanheyi7147 2012-05-10 23:48
    关注

    Marc is actually right in his solution. If I could try to elaborate a bit, when you include slide_auto.php, you can think the following happening:

    1. PHP inserts the text from the file slide_auto.php, where the include command is found.
    2. So, when $file_dir="slideS_img"; comes up it tries to find the directory under slideshowpage.php, not slide_auto.php.

    This fails because the actual image folder is in directory slideshow.

    If you call slide_auto.php directly (or within the Flash application), then its directory is slideshow, and you should be able to get the XML without any further errors.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效