php - When running the project I'm getting error: Warning: opendir failed to open dir: not implemented -
php - When running the project I'm getting error: Warning: opendir failed to open dir: not implemented -
in index.php
have code:
<?php $pattern="(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$) |(\.gif$)"; //valid image extensions $files = array(); $curimage=0; if($handle = opendir("http://newsxpressmedia.com/files/radar-simulation-files")) { while(false !== ($file = readdir($handle))){ if(eregi($pattern, $file)){ //if file valid image //output javascript array element $files[] = $file; $curimage++; } } closedir($handle); } ?> <!doctype html> <html> <head> <title>change picture</title> <link rel="stylesheet" type="text/css" href="/css/result-light.css"> <style type='text/css'> #timer_countdown{ background:black; color:yellow; font-weight:bold; text-align:center; } </style> <script type = "text/javascript"> function displaynextimage() { x = (x === images.length - 1) ? 0 : x + 1; document.getelementbyid("img").src = images[x]; } function displaypreviousimage() { x = (x <= 0) ? images.length - 1 : x - 1; document.getelementbyid("img").src = images[x]; } $json = json_encode($files); //json = <?php echo $json; ?> var images = json.parse(json); //var images = <?=json_encode($files)?>; //var images = []; var x = -1; var swap_hours = 0; var swap_minutes = 0; var swap_seconds = 5; var down_counter_hours; var down_counter_minutes; var down_counter_seconds; function inittimer() { down_counter_hours = swap_hours; down_counter_minutes = swap_minutes; down_counter_seconds = swap_seconds; counter = setinterval(switcher, 1000); } function restartcounter() { down_counter_hours = swap_hours; down_counter_minutes = swap_minutes; down_counter_seconds = swap_seconds; } function switcher() { down_counter_seconds--; if (down_counter_hours <= 0 && down_counter_minutes <= 0 && down_counter_seconds <= 0) { swapcolor(); restartcounter(); } if (down_counter_seconds <= 0 && down_counter_minutes > 0) { down_counter_seconds = 60; down_counter_minutes--; } if (down_counter_minutes <= 0 && down_counter_hours > 0) { down_counter_minutes = 60; down_counter_hours--; } document.getelementbyid("timer_countdown").innertext = down_counter_hours+":"+down_counter_minutes+":"+down_counter_seconds; } function swapcolor() { displaynextimage(); } </script> <div id="div_hours" class="div_box"></div> <div id="div_minutes" class="div_box"></div> <div id="div_seconds" class="div_box"></div> <div id="div_switcher" class="div_box"></div> </head> <body onload = "inittimer()"> <div id="timer_countdown"> </div> <img id="img" src="http://newsxpressmedia.com/files/theme/radar000005.gif"> <button onclick="displaypreviousimage(); restartcounter()">previous</button> <button onclick="displaynextimage(); restartcounter()">next</button> </body> </html>
my host website ipage.com in filemanager on ipage.com see directory files/radar-simulation-files root directory.
i'm using netbeans 8.0.1 , xampp run localhost apache server.
in netbeans when click run button it's going location:
http://localhost/phpproject2/index.php
and there, above first image see:
warning: opendir(http://newsxpressmedia.com/files/radar-simulation-files): failed open dir: not implemented in c:\xampp\htdocs\phpproject2\index.php on line 5
what want list of images in directory files/radar-simulation-files
edit
this code tried now:
<?php $username = 'my domain name'; $password = 'my pass'; $basepath = 'domains/newsxpressmedia.com/public_html/'; $handle = opendir("ftp://{$username}:{$password}@ftp.ipage.com/{$basepath}files/radar-simulation-files"); //$imgdir = 'images/'; //pick folder $allowed_types = array('png','jpg','jpeg','gif'); //allowed types of files //$dimg = opendir($imgdir);//open directory while($imgfile = \readdir(handle)) { if( in_array(strtolower(substr($imgfile,-3)),$allowed_types) or in_array(strtolower(substr($imgfile,-4)),$allowed_types) ) /*if file image add together array*/ {$a_img[] = $imgfile;} } echo "<ul>"; $totimg = count($a_img); //the total count of images //echo out images , paths incased in li. for($x=0; $x < $totimg; $x++){echo "<li><img src='" . $imgdir . $a_img[$x] . "' /></li>";} echo "</ul>"; ?> <!doctype html> <html> <head> <title>change picture</title> <link rel="stylesheet" type="text/css" href="/css/result-light.css"> <style type='text/css'> #timer_countdown{ background:black; color:yellow; font-weight:bold; text-align:center; } </style> <script type = "text/javascript"> function displaynextimage() { x = (x === images.length - 1) ? 0 : x + 1; document.getelementbyid("img").src = images[x]; } function displaypreviousimage() { x = (x <= 0) ? images.length - 1 : x - 1; document.getelementbyid("img").src = images[x]; } /* @var $ar type */ var images = <?php echo \json_encode($imgfile) ?>; //$json = json_encode($imgfile); //json = <?php echo $json; ?> //var images = json.parse(json); //var images = <?=json_encode($files)?>; //var images = []; var x = -1; var swap_hours = 0; var swap_minutes = 0; var swap_seconds = 5; var down_counter_hours; var down_counter_minutes; var down_counter_seconds; function inittimer() { down_counter_hours = swap_hours; down_counter_minutes = swap_minutes; down_counter_seconds = swap_seconds; counter = setinterval(switcher, 1000); } function restartcounter() { down_counter_hours = swap_hours; down_counter_minutes = swap_minutes; down_counter_seconds = swap_seconds; } function switcher() { down_counter_seconds--; if (down_counter_hours <= 0 && down_counter_minutes <= 0 && down_counter_seconds <= 0) { swapcolor(); restartcounter(); } if (down_counter_seconds <= 0 && down_counter_minutes > 0) { down_counter_seconds = 60; down_counter_minutes--; } if (down_counter_minutes <= 0 && down_counter_hours > 0) { down_counter_minutes = 60; down_counter_hours--; } document.getelementbyid("timer_countdown").innertext = down_counter_hours+":"+down_counter_minutes+":"+down_counter_seconds; } function swapcolor() { displaynextimage(); } </script> <div id="div_hours" class="div_box"></div> <div id="div_minutes" class="div_box"></div> <div id="div_seconds" class="div_box"></div> <div id="div_switcher" class="div_box"></div> </head> <body onload = "inittimer()"> <div id="timer_countdown"> </div> <img id="img" src="http://newsxpressmedia.com/files/theme/radar000005.gif"> <button onclick="displaypreviousimage(); restartcounter()">previous</button> <button onclick="displaynextimage(); restartcounter()">next</button> </body> </html>
i have uploaded file host domain ipage.com filemanager i'm browsing to:
my site
it start counting timer stop on 1
then i'm doing on website: inspect element , in console see error:
uncaught typeerror: cannot read property 'length' of null
on line 23
something wrong php code should images files , set them in array.
you can not utilize opendir
browse files on http. instead should seek ftp connection, like:
$username = 'ftp-username'; $password = 'ftp-password'; $basepath = 'domains/newsxpressmedia.com/public_html/'; $handle = opendir("ftp://{$username}:{$password}@ftp.ipage.com/{$basepath}files/radar-simulation-files")
php
Comments
Post a Comment