bluewalrus
12-19-2008, 12:53 AM
I'm trying to make a self contained php/javascript image gallery and I have it 95% there. I just can't get the getimagesize to work i have it written like this
list($width) = getimagesize($file);.
The gallery's basically there it's displaying the contents and it moves its just missing this one feature. I also don't know how its displaying the contents without this part but it is (I designed it to have this feature to know how far to go). Anyway...this is my error message:
Warning: getimagesize(): Read error! in /hsphere/local/home/crazychr/christophermacdonald.net/test/gal.php on line 129
This is the whole php code. I'd greatly appreciate any help with this. This is the best use of php I've had thus far and also would like to provide it working with the javascript to other users. I think, it's a pretty neat/simpleish code it reads a directory then writes the code of all image files in it. Tha java feature will be shown in a bit or you can see it on this page. http://www.christophermacdonald.net/test/gal.php Mouse over one of the arrows and observe the bottom right corner (haha i'm gonna play around with the css later.)
<?php
$size = 0;
$dirname = "../test/";
$dir = opendir($dirname);
while(false != ($file = readdir($dir)))
{
if(($file != ".") and ($file != ".."))
{
$fileChunks = explode(".", $file);
if($fileChunks[1] == 'jpg' || 'jpeg' || 'gif' || 'png' || 'tif') //interested in second chunk only
{
$file9 = "../test/images.txt";
//add image code to text file to display image after loop
$handle = fopen($file9, "a+");
$data = '<div class="image"><img src="' . $file . '" alt="esef user image" border="0" /></div>';
fwrite($handle, $data );
fclose($handle);
//get the image size
list($width) = getimagesize($file);
$size = $size + $width;
$file10 = "../test/size.txt";
//open the size text file and write the size of the new image plus the size of previous images into it
$handle2 = fopen($file10, "w+");
fwrite($handle2, $size);
fclose($handle2);
}
}
}
closedir($dir);
//write html page contents
$file3 = "../test/images.txt";
$handle3 = fopen($file3, "r");
$display = fread($handle3, 20000000);
fclose($handle3);
echo '<div id="frame"><div id="images_container" style="width:' . $size . '; overflow:hidden; height:430px;"><div id="images">' . $display . '</div></div></div></div></body></html>';
?>
Thanks for any help you can offer.
list($width) = getimagesize($file);.
The gallery's basically there it's displaying the contents and it moves its just missing this one feature. I also don't know how its displaying the contents without this part but it is (I designed it to have this feature to know how far to go). Anyway...this is my error message:
Warning: getimagesize(): Read error! in /hsphere/local/home/crazychr/christophermacdonald.net/test/gal.php on line 129
This is the whole php code. I'd greatly appreciate any help with this. This is the best use of php I've had thus far and also would like to provide it working with the javascript to other users. I think, it's a pretty neat/simpleish code it reads a directory then writes the code of all image files in it. Tha java feature will be shown in a bit or you can see it on this page. http://www.christophermacdonald.net/test/gal.php Mouse over one of the arrows and observe the bottom right corner (haha i'm gonna play around with the css later.)
<?php
$size = 0;
$dirname = "../test/";
$dir = opendir($dirname);
while(false != ($file = readdir($dir)))
{
if(($file != ".") and ($file != ".."))
{
$fileChunks = explode(".", $file);
if($fileChunks[1] == 'jpg' || 'jpeg' || 'gif' || 'png' || 'tif') //interested in second chunk only
{
$file9 = "../test/images.txt";
//add image code to text file to display image after loop
$handle = fopen($file9, "a+");
$data = '<div class="image"><img src="' . $file . '" alt="esef user image" border="0" /></div>';
fwrite($handle, $data );
fclose($handle);
//get the image size
list($width) = getimagesize($file);
$size = $size + $width;
$file10 = "../test/size.txt";
//open the size text file and write the size of the new image plus the size of previous images into it
$handle2 = fopen($file10, "w+");
fwrite($handle2, $size);
fclose($handle2);
}
}
}
closedir($dir);
//write html page contents
$file3 = "../test/images.txt";
$handle3 = fopen($file3, "r");
$display = fread($handle3, 20000000);
fclose($handle3);
echo '<div id="frame"><div id="images_container" style="width:' . $size . '; overflow:hidden; height:430px;"><div id="images">' . $display . '</div></div></div></div></body></html>';
?>
Thanks for any help you can offer.