2012-05-10 56 views
1

スライドショーを表示しようとしています。PHP&SWF - スライドショーが表示されない

<?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私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> 

私はここに私のslideS_imgフォルダ

は私slide_auto.phpファイルであるとして slide_auto.phpはで同じディレクトリですと言うエラーが表示されます警告:opendir(slideS_img)[function.opendir]:オープンに失敗しましたdir:/ [path]/slideshow/sliにこのようなファイルやディレクトリはありません62行目のde_auto.php

ヘルプがありますか? ありがとう

+0

try $ file_dir = './';あなたはそれらが同じフォルダにあると言っています –

+0

@Alexiosしかし、それは開く必要があるslidesS_imgディレクトリはどのように認識されますか? Ευχαριστώ;) – Pavlos1316

答えて

0

マークは実際には彼のソリューションの中にあります。私は少し手の込んだしようとすることができれば、あなたはslide_auto.phpを含む場合には、次の出来事を考えることができます:

  1. PHPには、コマンドが検出されたファイルslide_auto.php、からテキストを挿入します。
  2. したがって、$ file_dir = "slideS_img";それはslideshowpage.php、の下のディレクトリを見つけることを試みますslide_auto.php

実際の画像フォルダがディレクトリのスライドショーにあるため、これは失敗します。

slide_auto.phpを直接(またはFlashアプリケーション内で)呼び出すと、そのディレクトリはスライドショーになり、それ以上のエラーは発生せずにXMLを取得できるはずです。

+0

私は "slideS_img"を完全なパスで変更しました。 home/main/slideshow/slideS_imgとidはそれを見つけましたが、私の新しいエラーは "swfobjectが定義されていません"というものです。ありがとうございました – Pavlos1316

+0

swfobjectクラスが定義されている.jsファイルは含まれていません。 –

1

インクルードされたファイルは、それらのファイルの作業ディレクトリを想定しています。あなたの親スライドショースクリプトは、あなたのスライドショースクリプトの作業ディレクトリになるでしょう(例えば)

/home/sites/example.com/html 

にあります。だから、opendir関数は、実際に

/home/sites/example.com/html/slideS_img 

代わりの

/home/sites/example.com/html/slideshow/slideS_image 

あなたはより多くの特定のディレクトリを使用するようにopendir関数の呼び出しを変更する必要がありますように行われています。

+0

私のslideshowpage.phpは、slide_auto.phpとslideS_imgフォルダが入っている私のslideshowフォルダの外です。私はどこが間違っているのかわかりません。 – Pavlos1316

+0

いいえ、include()は、slideshowpage.phpが入っているディレクトリのサブディレクトリにslide_auto.phpがあることを示しています。 –

+0

私は混乱しています... slideshowpage.phpは[maindir]の下にあります。 slideS_imgフォルダとslide_auto.phpは[main/slideshow]の下にあります – Pavlos1316

関連する問題