Forum Moderators: coopster

Message Too Old, No Replies

PHP script rendering in all but Internet Explorer (all versions)

         

vampwizzard

7:09 pm on Sep 28, 2008 (gmt 0)

10+ Year Member



Hello. I am working on a script that goes through all the folders in the current directory and echo's them to html, similar to a photo album. This does not require a database. For some reason, the code works fine in firefox, safari, opera, and the other Gecko-engined browsers, but not IE. I find this to be annoying and I have no idea whats going on.

here is the code from start to finish:


<?php
$directory = "sissydoll/";
function loadMedia($dir){
echo "Current JPEGS in ". $dir."<p />";

// open specified directory

$dirHandle = opendir($dir);
$count = 0;
$returnstr = array();
while ($file = readdir($dirHandle)) {
// if not a subdirectory and if filename contains the string '.jpg'
if(!is_dir($file) && strpos($file, '.jpg')>0) {
// update count and string of files to be returned
$returnstr[$count] = $dir.$file;
$count++;
}
}
foreach($returnstr as $key => $value){
echo "<div style=\"float: left;width: auto;height: 150px;\"><a href=\"$value\"><img src=\"$value\" height=\"100px\" width=\"100px\"/></a><br />". $value. "<br /><a href=\"del.php".'?file='.$value."&dir=".$dir."\">Delete</a></div>";
}
closedir($dirHandle);}

?>



<html>
<title>Photo Manager<title>
<style type="text/css">
div{margin:5px;}</style>
<body>
<div style="position:absolute; top: 10%; left:5%;">
<form enctype="multipart/form-data" action="upload.php" method="POST" name="uploader">
<input type="hidden" name="MAX_FILE_SIZE" value="100000000" />
Where Would You Like This File to Go?
<select name="directory">
<?php
$directories = array();
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if(is_dir($file) && $file != "." && $file != "..")
{$directory = $file."/";
$directories[$directory] = $directory;
echo "<option value=\"$file\">$file</option>";

}
}
}
?>
</select><p />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />


</form><p/>
Click the following paths to see the pictures stored there:<p/>

<?php

foreach($directories as $keys => $values)
{
echo '<a href="photo.php?dir='.$values. '">'.$values.'</a><br />';
}
echo '<p/>';
$directory = $_GET['dir'];
if($directory == "")
{$directory = "sissydoll/";}
echo $directory.'<p>';

loadMedia($directory);

?>
</div>
</body>
</html>

vampwizzard

8:53 pm on Sep 28, 2008 (gmt 0)

10+ Year Member



I figured it out, html error I apologize