473,382 Members | 1,665 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,382 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 34245
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...
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
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.