Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determinate is there a picture

Status
Not open for further replies.

Regany

Programmer
Aug 27, 2004
72
LV
Is it possible to determinate if there is a picture under the source.

for example:
<img src='picture011.jpg'>
how to determinate is the 'pictere011.jpg' exists?
 
Try to fetch it? You could use fopen() or cURL functions for this.

If I wanted to do it as efficiently as possible, I might use fsockopen() and issue an HTTP "HEAD" request so that the foreign server does not try to actually send the file.



Want the best answers? Ask the best questions! TANSTAAFL!
 
You could use the [blue]file_exists()[/blue] function to find out wether it exists or not.


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
The use of file_exists() may or may not work.

The online manual entry for file_exists() states that the wrapper must support the stat() functionality for file_exists() to work.

The online manual section on supported wrappers [link] says HTTP and HTTPS do not support stat(). So file_exists() is not going to work with an HTTP resource.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Who said it was an HTTP or HTTPS resource. the OP just sated he wanted to check if a particular image file existed. They never stated it was located on another server or that is was accessed form somwhere else.

I assumed the file was supposed to be located in the same file system , hence file_exists should work.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
I'm not saying you disagree, just pointing out that it should work given the right circumstances.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top