If I understand the issue, you want to reference a file, you will know the filename, but the extension could be one of a few possibilities. Rather than getting a list of every file, I would be inclined to do it the other way and check the list of extensions. This will presumably be a much shorter list:
If you can't be bothered to post more than a few words, at least detailing some things like the actual output of the script and any debugging you've tried, I can't be bothered to help you fix it. Maybe if you show a bit of courtesy to the people going out of their way to help you, you will find people more willing to keep on helping.
I think you'll need to give us some more specific information about what you want to happen.
The script Mindzai posted will print off links to any images in the images/ directory with the name hello.png, hello.gif, hello.jpg or hello.jpeg. That could be modified slightly to fit what you said originally like this:
PHP Code:
<?php
$exts = array('png', 'gif', 'jpg', 'jpeg');
$file = "uploads/$script_id"; // <-- You'd have to define $script_id
$src = '';
foreach ($exts as $ext) {
if (file_exists("$file.$ext")) {
$src = "$file.$ext";
break;
}
}
Bookmarks