[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

php opendir() Not working on Windows Hosting on Godaddy

Posted on 2011-02-12
4
Medium Priority
?
1,373 Views
Last Modified: 2012-05-11
Transfer files from Unix to Windows now directories are not being read by my script.

Even if I try $imgdir = "D:\Hosting\zircobjj\gear\."; still doesn't work. Help is a ppreciated

Here is my code below:

$imgdir = "\gear";
$dimg = opendir($imgdir);
 while($imgfile = readdir($dimg))
 {
 if( (substr($imgfile,-3)=="gif") || (substr($imgfile,-3)=="jpg")  || (substr($imgfile,-3)=="JPG") || (substr($imgfile,-3)=="GIF")  )
 {
$a_img[count($a_img)] = $imgfile;
sort ($a_img);
reset ($a_img);
//shuffle ($a_img);
 }
}
0
Comment
Question by:mrroy69
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

by:mrroy69
ID: 34878221
Here is the full code:

<?php
$resultspage=$_REQUEST['resultspage'];
$imgdir = "gear";
$photo_dir = "";
$a_img = array();
$title = "Gear";


$col = 3; //no. of columns in a pageresult
$maxrow = 4; //no. of rows in a pageresult

$thumb = true ;

$space=" &nbsp; ";
print "";
print "";




$dimg = opendir($imgdir);
 while($imgfile = readdir($dimg))
 {
 if( (substr($imgfile,-3)=="gif") || (substr($imgfile,-3)=="jpg")  || (substr($imgfile,-3)=="JPG") || (substr($imgfile,-3)=="GIF")  )
 {
$a_img[count($a_img)] = $imgfile;
sort ($a_img);
reset ($a_img);
//shuffle ($a_img);
 }
}



 $totimg = count($a_img); // total images number
 $totxresultspage = $col*$maxrow; // images x pageresult
 $totresultspage = ($totimg%$totxresultspage==0)?((int)$totimg/$totxresultspage):((int)($totimg/$totxresultspage)+1); // number of total pageresults


/*********** NEW STUFF **************/


$display=$col * $maxrow;

$pagenums = ceil ($totimg/$display);

// if no value for resultspage, resultspage = 1
if ($resultspage == '') {
   $resultspage = 1;
};


// Create a start value
$start= ($resultspage - 1) * $display;

if ($totimg - $start < $display) {
$end_count = $totimg;
} elseif ($totimg - $start >= $display) {
$end_count = $start + $display;
}
 
 


if ($totimg - $end_count > $display) {
$var2 = $display;
} elseif ($totimg - $end_count <= $display) {
$var2 = $totimg - $end_count;
}
$space = " &nbsp; ";

/*********** END OF NEW STUFF ***********/



 if($totimg == false)
   print "";
 else
 {




print "<A NAME=PHOTO></a>\n
<table border='0'cellpadding='0'cellspacing='0'width='100%'>";
  // start resultspage
  if($resultspage=="" || $resultspage==1)
  {
   $x=0;
   $pageresult = 1;
  }
  else
   $x = (($resultspage-1)*($totxresultspage));
  $r=0;


  // print of table
  foreach($a_img as $key=>$val)
  {





   if(($x%$col)==0)
    print "<tr>\n";
   if($a_img[$x])
   {
$size = getimagesize ("$imgdir/$a_img[$x]");
$halfw = round($size[0]/2);
$halfh = round($size[1]/2);
$quarterw = round($size[0]/4);
$quarterh = round($size[1]/4);





if($size[1] < $size[0])
{

///// GET PROPORTIONAL DIMENSIONS ///////////
//list($width,$height)=getimagesize("$imgdir/$a_img[$x]");
// Set the new Width
//$newwidth1=300;

$newwidth1 = 200;

// Get the proportional height based on the width
//$getheight1=($newwidth1 / $width) * $height;
//$getheight=number_format($getheight1, 0);
//$newheight1=$getheight;
$newheight1 = 150;
///// END OF GET PROPORTIONAL DIMENSIONS ///////////

   $imgnumber = ($x+1);
    if("$imgdir/$a_img[$x]" !="")

if ($thumb){
$thumbnail = "$imgdir/$a_img[$x]\"";
}
else
{
$thumbnail =  "$imgdir/$a_img[$x]";
}

print "<td align='center'valign='middle'width='25%'height='230'>";
print'<table width="230" height="180" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3"><img src="images/phototop.jpg" width="230" height="15" alt="" /></td>
</tr>
<tr>
<td width="15"><img src="images/photoleft.jpg" width="15" height="150" alt="" /></td>
<td width="200"valign="top">';
print "<a href=\"$imgdir/".$a_img[$x]."\"rel='lightbox[wgn]'title=\"$title\"><img src=\"$thumbnail\" height='$newheight1' width='$newwidth1' border=0 alt=\"$title\"></a>";
print'</td>
<td width="15"><img src="images/photoright.jpg" width="15" height="150" alt="" /></td>
</tr>
<tr>
<td colspan="3"><img src="images/photobottom.jpg" width="230" height="15" alt="" /></td>
</tr>
</table>';
print"</td>\n";
}

else
{        

///// GET PROPORTIONAL DIMENSIONS ///////////
//list($width,$height)=getimagesize("$imgdir/$a_img[$x]");
// Set the new Width
//$newheight2=200;
$newheight2 = 200;


// Get the proportional height based on the width
//$getwidth1=($newheight2 / $height) * $width;
//$getwidth=number_format($getwidth1, 0);
//$newwidth2=$getwidth;
$newwidth2 = 150;
///// END OF GET PROPORTIONAL DIMENSIONS ///////////

if ($thumb){
$thumbnail = "$imgdir/$a_img[$x]\"";
}
else
{
$thumbnail =  "$imgdir/$a_img[$x]";
}

 $imgnumber = ($x+1);
    if("$imgdir/$a_img[$x]" !="")

print "<td align='center'valign='middle'width='25%'height='230'>";
print'<table width="180" height="230" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3"><img src="images/photovtop.jpg" width="180" height="15" alt="" /></td>
</tr>
<tr>
<td width="15"><img src="images/photovleft.jpg" width="15" height="200" alt="" /></td>
<td width="150" height="200"valign="top">';
print"<a href=\"$imgdir/".$a_img[$x]."\"rel='lightbox[wgn]'title=\"$title\"><img src=\"$thumbnail\" height='$newheight2' width='$newwidth2' border=0 alt=\"$title\"></a>";
print'</td>
<td width="15"><img src="images/photovright.jpg" width="15" height="200" alt="" /></td>
</tr>
<tr>
<td colspan="3"><img src="images/photovbottom.jpg" width="180" height="15" alt="" /></td>
</tr>
</table>';
print"</td>\n";
}
 
}
if(($x%$col) == ($col-1))
   {
    print "</tr>\n";
    $r++;
   }
  // print "r=$r - maxrow=$maxrow<br>";
   if($r==$maxrow)
   {
    break;
   }
   else
   $x++;
  }
  print "</table>";
 }
 // pageresult break
 
print "<br /><br /><table width='100%' border='0' cellpadding='2' cellspacing='0' align='center'><tr>
<td width='920'id='gallerypics'align='center'>\n";



/********** NEW STUFF ***********/
// previous link

if ($resultspage>1) {

echo "<a href='store.php?resultspage=".($resultspage-1)."&#PHOTO'>Previous</a>" . $space . "";
}


// dynamic page number links (make sure to change yourpage.php to the name of your page)


for ($i=1; $i<=$pagenums; $i++) {
if ($i!=$resultspage) {
echo "<a href='store.php?resultspage=$i&#PHOTO'>$i</a>$space";
}
else {
if($pagenums == "1"){
echo"";
}
else
{
echo "<b>$i</b>$space";
}

}
}
// next link (make sure to change yourpage.php to the name of your page)
if ($resultspage<$pagenums) {
echo "<a href='store.php?resultspage=".($resultspage+1)."&#PHOTO'>Next </a>";
}
print "</td></tr></table>";

?><br />
0
 
LVL 4

Accepted Solution

by:
JayDiablo earned 2000 total points
ID: 34879023
It's possible that GoDaddy's servers might have some PHP SAFE MODE security checks in place by default, thus preventing you from opening directories that are outside the folder that your PHP script resides in.

Are you getting any specific errors from your code?  (you may need to check in your server's error logs if nothing is outputting in the browser)
0
 

Author Comment

by:mrroy69
ID: 34879031
The folders are in the same directory. It doesn't display any error.
0
 
LVL 4

Expert Comment

by:JayDiablo
ID: 34879720
Do you have access to your server's error logs?  Perhaps there's something there that's useful.  Production systems shouldn't output errors to the browser, but should still log to a file.

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/bcabdcfb-2421-4eab-b5fb-777c791daaa9.mspx?mfr=true

Usually issues with opendir are permission related, but it's hard to troubleshoot if there are no errors.

You might want to try whipping together a quick script that just tries to open a single file (like a text file) inside that gears folder, and output it, just so you can confirm that PHP is able to read files in that directory.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First of all, clustering IIS is something you should rarely consider doing. In almost all cases, Microsoft Network Load Balancing (NLB) (http://technet.microsoft.com/en-us/library/cc758834(WS.10).aspx) is a much better solution when you need to p…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question