|
Posted by Jim Carlock on 01/03/06 22:05
"Jameson" <jameson_ray@comcast.net> wrote:
> Thanks for the new code. I think we're getting closer, but it still
> doesn't seem to be working.
Hi Ray,
Are you working in the MacIntosh environment? I'm working on
with a PC. On the PC, the php.ini file typically gets found in the
system32 folder. I'm not sure how things work on a MacIntosh,
so perhaps you can explain the php.ini concepts relating to
MacIntosh (if that is the case) for my benefit. The php stuff is
very new to me.
I did get the following code to work here, using glob(). I really
like this better than having to do mime_content_type stuff. And
so much in the PC and unix world seem very much related,
using file extensions to denote the contents of the file.
<html>
<head>
<title>List of Files</title>
</head>
<body>
<p><?php
$dir = '.';
$sAltText = "Picture";
foreach (glob("*.jpg") as $file) {
echo "file: $file<br />\n";
echo "<i>filename:</i> <b>$file</b>, <i>filetype:</i> <b>" . filetype($file) . "</b><br />\n";
echo '<img src="' . $file . '" border="0" alt="$sAltText" /><br />' . "\n";
}
?></p>
</body></html>
> I added the error reporting code below to the file, but it doesn't
> tell me that anything is wrong. It's strange, because I don't even
> see an icon from the browser saying that it can't find the image.
When you view the page through the browser, take a look at the
source code (the HTML output). The code I posted previously
seems to have had a small bug in one of the lines, and I gave up
testing it when I couldn't get the php_mime_magic.dll to provide
the php_mime_content() function. So I don't know how the
Mac environment works, nor the Unix environment. The file name
could possibly be of a different extension in each environment. If
anyone else here can provide a little help here that would be
great.
> Do you think I could be missing some component of my PHP
> installation? I know the directory path is fine, because I can get
> to it right from the terminal on the computer.
ini_set("display_errors",true);
error_reporting(E_ALL );
> Any more ideas? Do you think if I used the glob() function within
> the opendir() function, it might work?
glob() is alot easier... there's no need for opendir() and readdir()
when using the glob function.
I just tested the following out and it works quite well.
<?php
$dir = '.';
$sAltText = "Picture";
foreach (glob("*.jpg") as $file) {
echo "file: $file<br />\n";
echo "<i>filename:</i> <b>$file</b>, <i>filetype:</i> <b>" . filetype($file) . "</b><br />\n";
echo '<img src="' . $file . '" border="0" alt="$sAltText" /><br />' . "\n";
}
?>
> Thanks again for the help. I really appreciate it!
You're welcome. I'm learning as well. So thanks back at you!
My mime_content_type() function is failing I think, because
the directory path for the php install folder is set to C:\php4
and php isn't installed there. So I guess I need to find the
source code for that particular DLL and modify the source
code. If anyone knows where to pick up the source code
for the php_mime_magic.dll feel free to leave a hint. It's a
shame (for me and others) that the people that compiled it
used an absolute path inside the DLL file.
Jim Carlock
Post replies to the newsgroup.
[Back to original message]
|