473,372 Members | 1,104 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,372 software developers and data experts.

Check if a file exists

is there a way to check if a file exists using php? i want to check if a
picture exists, and if not, use a picture saying that the picture couldn't
be found.

TIA
Jul 17 '05 #1
4 34244
Matthew Robinson wrote:
is there a way to check if a file exists using php?


It's quicker to look in the manual yourself than post a question here and
wait for an answer.

<URL:http://www.php.net/manual/en/function.file-exists.php>
--
Jim Dabell

Jul 17 '05 #2
"Matthew Robinson" a crit le 07/01/2004 :
is there a way to check if a file exists using php? i want to check if a
picture exists, and if not, use a picture saying that the picture couldn't
be found.

TIA


use function file_exists();

--
Have you read the manual?
http://www.php.net/manual/en/

Jul 17 '05 #3
thanks
Jul 17 '05 #4
On Wed, 07 Jan 2004 19:07:46 +0000, Matthew Robinson wrote:
is there a way to check if a file exists using php? i want to check if a
picture exists, and if not, use a picture saying that the picture couldn't
be found.

TIA


I've been using something along the lines of this:

$filename=($dbrow['hexid'] . ".jpg");

if (file_exists($filename))
{
printf("<img src=\"%s.jpg\" alt=\"%s\" />\n<br />", $dbrow["id"],
$dbrow["name"]);
}
else
{
printf("<img src=\"notfound.jpg\" alt=\"no image available\" />\n<br />");
}

Which is probably not a very elegant way of doing things, but it 'works
for me(tm)'.

Jul 17 '05 #5

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

Similar topics

3
by: newcomer | last post by:
Is there a way to check if a file exists in Javascript? This is what I'm trying to do: if(thisfile.htm exists) do this else do that
10
by: Raymond | last post by:
Hi All: To find a file exists using the file name, I have tow routings on UNIX system. 1. access(2) 2. lstat(2) This tow function also can do. When the return value is "-1" and errno is...
7
by: andylcx | last post by:
Hi all: The c++ language can check whether the file exist or not. I am wondering how c language does this job? Thanks a lot! Andy
5
by: jez123456 | last post by:
Hi, I’ve written a c# program to compact certain msaccess databases. The way this works is to compact say C:\test1.mdb to C:\temp.mdb, then delete C:\test1.mdb and rename C:\temp.mdb as...
2
by: Adrian | last post by:
hi I'm writing, or trying to! an ASP page that checks if a file exists and if so transfers it. the use sends a query string with the name of the file, I have this bit working, but need to check...
10
by: Ricardo Luceac | last post by:
Hi all. I'm having a problem with this, I have look if a file exists, if don't wait till it is created and if it exists I need to open it. I do the following: for (; ; ) {
5
by: sword | last post by:
How can I check whether a file exists?
14
by: John Salerno | last post by:
What is the best way to check if a file already exists in the current directory? I saw os.path.isfile(), but I'm not sure if that does more than what I need. I just want to check if a file of a...
3
by: trint | last post by:
How can I do this with my c# code with my website(because the file is there, but the code doesn't return it)?: if(File.Exists(String.Format("~/images/categories/{0}", sFileName)) return...
2
Manikgisl
by: Manikgisl | last post by:
HI. How to check File exists in Web Share C# try { WebRequest request = HttpWebRequest.Create("http://www.microsoft.com/NonExistantFile.aspx"); request.Method = "HEAD"; // Just get...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.