473,394 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Find a file using php

In a directory, how to find an image file with part of its filename is known
and the file extension could be one of the following(jpg, tiff, bmp,png).

The filename always begin between 1 to 3 alphabet, then a dash(-), and
between 1-4 set of numbers and the extension could be in one of the
following(in order of importance) - jpg, bmp, tif.

If I know part/full of its filename, find the 1st match(just in case there
are similar filename) with .jpg extension, if not found, then check with
..bmp extension, last check if it is with .tif extension.
If still not found, then display no-image.jpg and exit.

e.g:

AA-123 one.tif
AA-123 two.bmp
AA-123 two.jpg
AA-123.jpg
B-34.jpg
B-34xxxx.tif
B yyyy.jpg
....
....

Jul 17 '05 #1
4 1981
"Ruby Tuesday" <ru*********@yahoo.com> wrote:
In a directory, how to find an image file with part of its filename is
known and the file extension could be one of the following(jpg, tiff,
bmp,png).


Check out fnmatch():
http://uk.php.net/manual/en/function.fnmatch.php

JOn
Jul 17 '05 #2
Thank Jon.

How do I put priorities on the findings if it returns a list of files?
Thanks

"Jon Kraft" <jo*@jonux.co.uk> wrote in message
news:Xn*************************@130.133.1.4...
"Ruby Tuesday" <ru*********@yahoo.com> wrote:
In a directory, how to find an image file with part of its filename is
known and the file extension could be one of the following(jpg, tiff,
bmp,png).


Check out fnmatch():
http://uk.php.net/manual/en/function.fnmatch.php

JOn

Jul 17 '05 #3
"Ruby Tuesday" <ru*********@yahoo.com> wrote:
"Jon Kraft" <jo*@jonux.co.uk> wrote:
"Ruby Tuesday" <ru*********@yahoo.com> wrote:
> In a directory, how to find an image file with part of its filename is > known and the file extension could be one of the following(jpg, tiff,
> bmp,png).


Check out fnmatch():
http://uk.php.net/manual/en/function.fnmatch.php


How do I put priorities on the findings if it returns a list of files?


Well, you would match against jpg, bmp, etc... and build the priority
logic in PHP code, e.g. if statement or switch()

JOn
Jul 17 '05 #4
Thanks again.

The switch prioritize it from top to bottom isn't it? Thanks

"Jon Kraft" <jo*@jonux.co.uk> wrote in message
news:Xn**************************@130.133.1.4...
"Ruby Tuesday" <ru*********@yahoo.com> wrote:
"Jon Kraft" <jo*@jonux.co.uk> wrote:
"Ruby Tuesday" <ru*********@yahoo.com> wrote:

> In a directory, how to find an image file with part of its filename is > known and the file extension could be one of the following(jpg, tiff,
> bmp,png).

Check out fnmatch():
http://uk.php.net/manual/en/function.fnmatch.php


How do I put priorities on the findings if it returns a list of files?


Well, you would match against jpg, bmp, etc... and build the priority
logic in PHP code, e.g. if statement or switch()

JOn

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Peter Hansen | last post by:
Greetings. Im trying to write a program that can be run from the command line. If I want to search for example after a file with the ending .pdf, I should be able to write in the command line:...
1
by: Harsha | last post by:
I have been working on VB, ASP for quite a long time. Very Recently ( From past 1 month) I am managing a VC++ project. I am trying to use the code which i downloaded from the internet to find the...
5
by: Tim Eliot | last post by:
Just wondering if anyone has hit the following issue and how you might have sorted it out. I am using the command: DoCmd.TransferText acExportMerge, , stDataSource, stFileName, True after...
1
by: Xiangliang Meng | last post by:
Hi, all. Recently, I find there is a way in our project to maintain a global set in many files by using preprocessing directives. I'm wondering if we could find a better method for this. Many...
1
by: marty.gagnon | last post by:
I have a xsl file that references a xml file using the document() function. I'm having trouble specifying the URI in the document() function of a xls stylesheet. I'm using java to transform the...
2
stealwings
by: stealwings | last post by:
Hello everyone; Its me again, I was wondering if some one can give me some guidelines about how to Find and replace a string after reading it from a file using i/o commands I mean, I have a file...
4
by: Leon | last post by:
Hi everybody, I am a beginer for Python, hope can get help from you guys. What I want to do is : Input an ID -find the ID in the file -copy the whole string <str id='xxx'>yyyyy</str> ...
4
by: =?Utf-8?B?VG9yZW4gVmFsb25l?= | last post by:
Was editing code, am getting the following errors } expected Type or namespace definition, or end-of-file expected Eyes crossed cannot find code below! using System; using...
2
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. creating a method to search a tree to find the position of node and to return its pointer value basically i...
4
by: Salad | last post by:
I have a situation where some, not all, users get the message "Couldn't find file "F:\AccessApps\AppName.mdw". This file is required for startup". My app the users are attempting to access is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.